tr181: fix compiler warnings

- 1 set but not used.
- multiple strncpy size out of bounds.

Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
This commit is contained in:
Daniel Danzberger 2020-03-25 18:00:00 +01:00
parent 0fa3f64981
commit e22c34b15e
2 changed files with 7 additions and 7 deletions

View file

@ -1957,7 +1957,7 @@ static int set_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data,
}
/* Combine vid wd linker. */
char new_if[50] = {0};
char new_if[64] = {0};
snprintf(new_if, sizeof(new_if), "%s.%s", intf, vlan_id);
/* Check if the new name is present in UCI. If yes do nothing, if no

View file

@ -180,11 +180,11 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
if (*ifname == '\0')
continue;
char intf[250] = {0};
strncpy(intf, ifname, sizeof(intf));
strncpy(intf, ifname, sizeof(intf) - 1);
char *if_name = strtok(intf, " ");
if (NULL != if_name) {
char name[250] = {0};
strncpy(name, if_name, sizeof(name));
strncpy(name, if_name, sizeof(name) - 1);
int macvlan = 0;
char *p = strstr(name, ".");
if (!p) {
@ -194,16 +194,16 @@ int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
else
continue;
}
char *tok, *end;
char *end;
if (macvlan == 1)
tok = strtok_r(name, "_", &end);
strtok_r(name, "_", &end);
else
tok = strtok_r(name, ".", &end);
strtok_r(name, ".", &end);
if (end == NULL)
continue;
if (macvlan == 0) {
char tag[20] = {0};
strncpy(tag, end, sizeof(tag));
strncpy(tag, end, sizeof(tag) - 1);
if (strncmp(tag, "1", sizeof(tag)) == 0)
continue;
}