From: Roy Marples Date: Sat, 21 Apr 2012 11:59:24 +0000 (+0000) Subject: Fix valid length checks for single ipv4 addresses X-Git-Tag: v5.6.0~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1031ae23059afd47926d52b47fa57c8a4ec4a840;p=thirdparty%2Fdhcpcd.git Fix valid length checks for single ipv4 addresses --- diff --git a/dhcp.c b/dhcp.c index f39e7835..742e352d 100644 --- a/dhcp.c +++ b/dhcp.c @@ -272,6 +272,9 @@ valid_length(uint8_t option, int dl, int *type) opt->type & (STRING | RFC3442 | RFC5969)) return 0; + if (opt->type & IPV4 && opt->type & ARRAY) + return (dl % sizeof(uint32_t) == 0 ? 0 : -1); + sz = 0; if (opt->type & (UINT32 | IPV4)) sz = sizeof(uint32_t); @@ -279,9 +282,8 @@ valid_length(uint8_t option, int dl, int *type) sz = sizeof(uint16_t); if (opt->type & UINT8) sz = sizeof(uint8_t); - if (opt->type & (IPV4 | ARRAY)) - sz = dl % sizeof(uint32_t); - return (dl == sz ? 0 : -1); + /* If we don't know the size, assume it's valid */ + return (sz == 0 || dl == sz ? 0 : -1); } /* unknown option, so let it pass */