summaryrefslogtreecommitdiffhomepage
path: root/src/dhcpv4.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2018-05-15 22:22:30 +0200
committerHans Dedecker <dedeckeh@gmail.com>2018-05-15 22:22:30 +0200
commitf2aa383f9ca085f4e261703d71b9039b487b89bb (patch)
tree4d7968281e2a61dbb0646081ebf28e3b0a5df274 /src/dhcpv4.c
parent4591b362e2435ea7ffcb6b02b1975d37b348268f (diff)
dhcpv4: fix out of bound access in dhcpv4_put
Detected by Coverity in CID 1433363 and 1432121 Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r--src/dhcpv4.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c
index 2b30307..b803359 100644
--- a/src/dhcpv4.c
+++ b/src/dhcpv4.c
@@ -493,7 +493,9 @@ static void dhcpv4_put(struct dhcpv4_message *msg, uint8_t **cookie,
uint8_t type, uint8_t len, const void *data)
{
uint8_t *c = *cookie;
- if (*cookie + 2 + len > (uint8_t*)&msg[1])
+ uint8_t *end = (uint8_t *)msg + sizeof(*msg);
+
+ if (*cookie + 2 + len > end)
return;
*c++ = type;