]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Fix NULL pointer dereference in lldpd_dot3_power_pd_pse 271/head
authoraxjowa <johnnyw@axis.com>
Mon, 26 Feb 2018 16:00:29 +0000 (17:00 +0100)
committeraxjowa <johnnyw@axis.com>
Mon, 26 Feb 2018 16:00:29 +0000 (17:00 +0100)
selected_port might be NULL after the loop if, for example,
no PSE was found among the neighbours.

This fixes a crash that occured with a device connected to
a non-PoE, LLDP-enabled switch via a PoE midspan.

src/daemon/lldpd.c

index 51d690fe4371bdd0fa5cbfa489c39719da9fadbf..7b5c1267de3e279b7cb3e19461a0422e9275a8d7 100644 (file)
@@ -974,7 +974,7 @@ lldpd_dot3_power_pd_pse(struct lldpd_hardware *hardware)
                if (!selected_port || port->p_lastupdate > selected_port->p_lastupdate)
                        selected_port = port;
        }
-       if (selected_port->p_power.allocated != hardware->h_lport.p_power.allocated) {
+       if (selected_port && selected_port->p_power.allocated != hardware->h_lport.p_power.allocated) {
                log_info("receive", "for %s, PSE told us allocated is now %d instead of %d",
                    hardware->h_ifname,
                    selected_port->p_power.allocated,