From: Vincent Bernat Date: Tue, 9 Dec 2008 17:16:49 +0000 (+0100) Subject: Do not share port id with interface MAC address (port id can be freed, X-Git-Tag: 0.3~12^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4395f9c11b13e9959f33ba07631e5039f6c0d7a4;p=thirdparty%2Flldpd.git Do not share port id with interface MAC address (port id can be freed, while interface MAC address is staticaly allocated) --- diff --git a/src/lldpd.c b/src/lldpd.c index f29c9d6b..7892553d 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -550,7 +550,9 @@ lldpd_port_add(struct lldpd *cfg, struct ifaddrs *ifa) lladdr = (u_int8_t*)(((struct sockaddr_ll *)ifa->ifa_addr)->sll_addr); memcpy(&hardware->h_lladdr, lladdr, sizeof(hardware->h_lladdr)); port->p_id_subtype = LLDP_PORTID_SUBTYPE_LLADDR; - port->p_id = (char*)hardware->h_lladdr; + if ((port->p_id = calloc(1, sizeof(hardware->h_lladdr))) == NULL) + fatal(NULL); + memcpy(port->p_id, hardware->h_lladdr, sizeof(hardware->h_lladdr)); port->p_id_len = sizeof(hardware->h_lladdr); port->p_descr = hardware->h_ifname;