(SIGAR-137) ensure net_interface_list names are null-byte terminated
Signed-off-by: Doug MacEachern <dougm@hyperic.com>
This commit is contained in:
parent
b48fd1e62f
commit
15bfbfef0e
|
@ -2447,8 +2447,10 @@ static int sigar_ifmsg_iter(sigar_t *sigar, ifmsg_iter_t *iter)
|
|||
case IFMSG_ITER_LIST:
|
||||
SIGAR_NET_IFLIST_GROW(iter->data.iflist);
|
||||
|
||||
/* sdl_data doesn't include a trailing \0, it is only sdl_nlen long */
|
||||
name = malloc(sdl->sdl_nlen+1);
|
||||
memcpy(name, sdl->sdl_data, sdl->sdl_nlen+1);
|
||||
memcpy(name, sdl->sdl_data, sdl->sdl_nlen);
|
||||
name[sdl->sdl_nlen] = '\0'; /* add the missing \0 */
|
||||
|
||||
iter->data.iflist->data[iter->data.iflist->number++] = name;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue