]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
We can work with saved leases without a full vendor area.
authorRoy Marples <roy@marples.name>
Wed, 1 Jun 2016 05:44:22 +0000 (05:44 +0000)
committerRoy Marples <roy@marples.name>
Wed, 1 Jun 2016 05:44:22 +0000 (05:44 +0000)
dhcp.c

diff --git a/dhcp.c b/dhcp.c
index 3c25dc0f979c5a395af4f236e24c94e7001b5211..f0057fb93bf6d03ce646a45d9d63da887a04f19c 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -1165,7 +1165,12 @@ read_lease(struct interface *ifp, struct bootp **bootp)
                return 0;
        }
 
-       if (bytes < sizeof(**bootp)) {
+       /* Ensure the packet is at lease BOOTP sized
+        * with a vendor area of 4 octets
+        * (it should be more, and our read packet enforces this so this
+        * code should not be needed, but of course people could
+        * scribble whatever in the stored lease file. */
+       if (bytes < offsetof(struct bootp, vend) + 4) {
                free(lease);
                logger(ifp->ctx, LOG_ERR, "%s: truncated lease", __func__);
                return 0;