]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Do not share port id with interface MAC address (port id can be freed,
authorVincent Bernat <bernat@luffy.cx>
Tue, 9 Dec 2008 17:16:49 +0000 (18:16 +0100)
committerVincent Bernat <bernat@luffy.cx>
Tue, 9 Dec 2008 17:16:49 +0000 (18:16 +0100)
while interface MAC address is staticaly allocated)

src/lldpd.c

index f29c9d6bb74a96da801d0bff804f4ceb75ec9ce1..7892553dc571b297ba9905875e37bbc42fe39b5f 100644 (file)
@@ -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;