(SIGAR-137) ensure net_interface_list names are null-byte terminated

Signed-off-by: Doug MacEachern <dougm@hyperic.com>
This commit is contained in:
Jan Kneschke 2009-01-26 12:21:09 -08:00 committed by Doug MacEachern
parent b48fd1e62f
commit 15bfbfef0e
1 changed files with 3 additions and 1 deletions

View File

@ -2447,8 +2447,10 @@ static int sigar_ifmsg_iter(sigar_t *sigar, ifmsg_iter_t *iter)
case IFMSG_ITER_LIST: case IFMSG_ITER_LIST:
SIGAR_NET_IFLIST_GROW(iter->data.iflist); 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); 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; iter->data.iflist->data[iter->data.iflist->number++] = name;
break; break;