View | Details | Raw Unified | Return to bug 231996 | Differences between
and this patch

Collapse All | Expand All

(-)files/patch-agent_mibgroup_if-mib_data__access_interface__sysctl.c (+28 lines)
Line 0 Link Here
1
--- agent/mibgroup/if-mib/data_access/interface_sysctl.c.orig	2018-07-16 14:33:40 UTC
2
+++ agent/mibgroup/if-mib/data_access/interface_sysctl.c
3
@@ -531,7 +531,8 @@ netsnmp_arch_interface_container_load(netsnmp_containe
4
                 }
5
             }
6
             adl = (struct sockaddr_dl *) a;
7
-            if_name = (char *) adl->sdl_data;
8
+            if_name = malloc(adl->sdl_nlen + 1);
9
+            memcpy(if_name, adl->sdl_data, adl->sdl_nlen);
10
             if_name[adl->sdl_nlen] = '\0';
11
         }
12
         if (!(ifp->ifm_addrs & RTA_IFP) || if_name == NULL) {
13
@@ -545,6 +546,7 @@ netsnmp_arch_interface_container_load(netsnmp_containe
14
             netsnmp_access_interface_container_free(container,
15
                                                     NETSNMP_ACCESS_INTERFACE_FREE_NOFLAGS);
16
             free(if_list);
17
+            free(if_name);
18
             return -3;
19
         }
20
 
21
@@ -563,6 +565,7 @@ netsnmp_arch_interface_container_load(netsnmp_containe
22
             entry->paddr_len = 6;
23
             memset(entry->paddr, 0, 6);
24
         }
25
+        free(if_name);
26
 
27
         entry->mtu = ifp->ifm_data.ifi_mtu;
28
         entry->type = ifp->ifm_data.ifi_type;

Return to bug 231996