From e22c34b15e75718aae40d7fd3edb6f3ce5dd5032 Mon Sep 17 00:00:00 2001 From: Daniel Danzberger Date: Wed, 25 Mar 2020 18:00:00 +0100 Subject: [PATCH] tr181: fix compiler warnings - 1 set but not used. - multiple strncpy size out of bounds. Signed-off-by: Daniel Danzberger --- dmtree/tr181/bridging.c | 2 +- dmtree/tr181/interfacestack.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dmtree/tr181/bridging.c b/dmtree/tr181/bridging.c index 2e8742e9..3c485790 100644 --- a/dmtree/tr181/bridging.c +++ b/dmtree/tr181/bridging.c @@ -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 diff --git a/dmtree/tr181/interfacestack.c b/dmtree/tr181/interfacestack.c index 3bd4b916..78f81494 100644 --- a/dmtree/tr181/interfacestack.c +++ b/dmtree/tr181/interfacestack.c @@ -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; }