diff options
| author | Roy Marples <roy@marples.name> | 2012-11-14 10:13:56 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2012-11-14 10:13:56 +0000 |
| commit | 7b44e21ed573346cea850ed59cdbfdd74ddaaf00 (patch) | |
| tree | c977085b0d92eb68f8187ed8e23b7754d3be6647 | |
| parent | 02c23488e622d0d62b645d3d34fd7e568b7578c6 (diff) | |
| download | dhcpcd-7b44e21ed573346cea850ed59cdbfdd74ddaaf00.tar.xz | |
More fixes to validation lengths.
| -rw-r--r-- | dhcp.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -272,8 +272,11 @@ validate_length(uint8_t option, int dl, int *type) opt->type & (STRING | RFC3442 | RFC5969)) return dl; - if (opt->type & IPV4 && opt->type & ARRAY) - return (dl % sizeof(uint32_t) == 0 ? 0 : -1); + if (opt->type & IPV4 && opt->type & ARRAY) { + if (dl < (int)sizeof(uint32_t)) + return -1; + return dl - (dl % sizeof(uint32_t)); + } sz = 0; if (opt->type & (UINT32 | IPV4)) @@ -285,7 +288,7 @@ validate_length(uint8_t option, int dl, int *type) /* If we don't know the size, assume it's valid */ if (sz == 0) return dl; - return sz; + return (sz < dl ? -1 : sz); } /* unknown option, so let it pass */ |
