]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Use ERANGE to differentiate from EINVAL to detect option length overflow.
authorRoy Marples <roy@marples.name>
Tue, 5 Jan 2016 13:49:41 +0000 (13:49 +0000)
committerRoy Marples <roy@marples.name>
Tue, 5 Jan 2016 13:49:41 +0000 (13:49 +0000)
dhcp.c
dhcp6.c

diff --git a/dhcp.c b/dhcp.c
index b5b2fd85260efe4884d4beacd6f40a53fa65a9c4..10916344fec84c1b3d2ebaad96c09a39de6e72ec 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -1225,7 +1225,7 @@ dhcp_getoption(struct dhcpcd_ctx *ctx,
                *code = (unsigned int)*od++;
                *len = (size_t)*od++;
                if (*len > ol - *os) {
-                       errno = EINVAL;
+                       errno = ERANGE;
                        return NULL;
                }
        }
diff --git a/dhcp6.c b/dhcp6.c
index 7933cb3af1ad1bed1b5edb5de3b2622140762c49..5f8ced85a48752dffcd09fe5bc9edd1cd2d5bab0 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -261,7 +261,7 @@ dhcp6_getoption(struct dhcpcd_ctx *ctx,
                o = (const struct dhcp6_option *)od;
                *len = ntohs(o->len);
                if (*len > ol - *os) {
-                       errno = EINVAL;
+                       errno = ERANGE;
                        return NULL;
                }
                *code = ntohs(o->code);