dhcpv6: harden reconfigure logic
authorHans Dedecker <dedeckeh@gmail.com>
Tue, 8 Dec 2020 17:43:38 +0000 (18:43 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Tue, 8 Dec 2020 17:46:54 +0000 (18:46 +0100)
Check if a valid DHCPv6 message is returned by dhcpv6_request in
dhcpv6_poll_reconfigure as only RENEW/REBIND/INFORMATION REQUEST
messages can trigger the transmission of these messages in reply
to a RECONFIGURE

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/dhcpv6.c

index 312e7aa80c0df266593a2a3af608f548e2254c63..b9eac435f85defeaa7b5363673be4553ce3d201e 100644 (file)
@@ -849,8 +849,21 @@ int dhcpv6_poll_reconfigure(void)
 {
        int ret = dhcpv6_request(DHCPV6_MSG_UNKNOWN);
 
-       if (ret != -1)
+       switch (ret) {
+       /*
+        * Only RENEW/REBIND/INFORMATION REQUEST
+        * messaage transmission can be requested
+        * by a RECONFIGURE
+        */
+       case DHCPV6_MSG_RENEW:
+       case DHCPV6_MSG_REBIND:
+       case DHCPV6_MSG_INFO_REQ:
                ret = dhcpv6_request(ret);
+               break;
+
+       default:
+               break;
+       }
 
        return ret;
 }