From: Roy Marples Date: Tue, 5 Jan 2016 13:49:41 +0000 (+0000) Subject: Use ERANGE to differentiate from EINVAL to detect option length overflow. X-Git-Tag: v6.10.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acd4eff9f93cd3fc7b605a6fdae7ba38ad2f67a7;p=thirdparty%2Fdhcpcd.git Use ERANGE to differentiate from EINVAL to detect option length overflow. --- diff --git a/dhcp.c b/dhcp.c index b5b2fd85..10916344 100644 --- 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 7933cb3a..5f8ced85 100644 --- 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);