summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2012-11-14 10:13:56 +0000
committerRoy Marples <roy@marples.name>2012-11-14 10:13:56 +0000
commit7b44e21ed573346cea850ed59cdbfdd74ddaaf00 (patch)
treec977085b0d92eb68f8187ed8e23b7754d3be6647
parent02c23488e622d0d62b645d3d34fd7e568b7578c6 (diff)
downloaddhcpcd-7b44e21ed573346cea850ed59cdbfdd74ddaaf00.tar.xz
More fixes to validation lengths.
-rw-r--r--dhcp.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/dhcp.c b/dhcp.c
index acc2b54c..660d31d1 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -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 */