From 15bfbfef0e6a05e0645d30ace77cded55d750859 Mon Sep 17 00:00:00 2001 From: Jan Kneschke Date: Mon, 26 Jan 2009 12:21:09 -0800 Subject: [PATCH] (SIGAR-137) ensure net_interface_list names are null-byte terminated Signed-off-by: Doug MacEachern --- src/os/darwin/darwin_sigar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 6d282837..9f0bb8ed 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -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;