gdhcp: The last option in a message was not parsed correctly
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Fri, 26 Apr 2013 06:51:32 +0000 (09:51 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 26 Apr 2013 10:06:57 +0000 (13:06 +0300)
If the desired option was last one in the message, then it was
lost because the remaining data calculation was wrong.

gdhcp/common.c

index e8676f8..0c433dd 100644 (file)
@@ -172,8 +172,8 @@ uint8_t *dhcpv6_get_option(struct dhcpv6_packet *packet, uint16_t pkt_len,
                if (opt_code == code) {
                        if (option_len != NULL)
                                *option_len = opt_len;
-                       if (rem == 0)
-                               found = NULL;
+                       if (rem < 0)
+                               goto bad_packet;
                        else
                                found = optionptr + 2 + 2;
                        count++;