mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-03-14 21:20:28 +01:00
tr181: ieee1905: fix invalid use of strncat
- Using strncat with source string lenght as limit makes no sense - Fixes potential stack overflow of list_val - No need to 0 initialize full list_val buffer Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
This commit is contained in:
parent
a07102c32b
commit
5eaa3d3906
1 changed files with 10 additions and 11 deletions
|
|
@ -1459,24 +1459,23 @@ static int get_IEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTuple_InterfaceLis
|
|||
{
|
||||
json_object *tuple;
|
||||
char *tuple_mac = NULL, *interface = NULL;
|
||||
char list_val[512] = {0};
|
||||
char list_val[512];
|
||||
int i = 0;
|
||||
unsigned pos = 0;
|
||||
|
||||
list_val[0] = 0;
|
||||
dmjson_foreach_value_in_array((json_object *)data, tuple, tuple_mac, i, 1, "br_mac") {
|
||||
|
||||
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIEEE1905%cAL%cNetworkTopology%cIEEE1905Device%c", dmroot, dm_delim, dm_delim, dm_delim, dm_delim, dm_delim), tuple_mac, &interface);
|
||||
if (interface == NULL)
|
||||
continue;
|
||||
|
||||
if (*list_val == '\0')
|
||||
strncat(list_val, interface, strlen(interface));
|
||||
else {
|
||||
strncat(list_val, ",", 1);
|
||||
strncat(list_val, interface, strlen(interface));
|
||||
}
|
||||
if (interface)
|
||||
pos += snprintf(&list_val[pos], sizeof(list_val) - pos, "%s,", interface);
|
||||
}
|
||||
|
||||
dmasprintf(value, "%s", list_val);
|
||||
/* cut tailing ',' */
|
||||
if (pos)
|
||||
list_val[pos - 1] = 0;
|
||||
|
||||
*value = dmstrdup(list_val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue