diff options
-rw-r--r-- | dhcp.c | 3 | ||||
-rw-r--r-- | dhcp6.c | 3 |
2 files changed, 4 insertions, 2 deletions
@@ -1257,12 +1257,13 @@ dhcp_getoption(struct dhcpcd_ctx *ctx, *os = 2; /* code + len */ *code = (unsigned int)*od++; *len = (size_t)*od++; - if (*len > ol) { + if (*len > ol - *os) { errno = EINVAL; return NULL; } } + *oopt = NULL; for (i = 0, opt = ctx->dhcp_opts; i < ctx->dhcp_opts_len; i++, opt++) { if (opt->option == *code) { *oopt = opt; @@ -258,7 +258,7 @@ dhcp6_getoption(struct dhcpcd_ctx *ctx, } o = (const struct dhcp6_option *)od; *len = ntohs(o->len); - if (*len > ol) { + if (*len > ol - *os) { errno = EINVAL; return NULL; } @@ -266,6 +266,7 @@ dhcp6_getoption(struct dhcpcd_ctx *ctx, } else o = NULL; + *oopt = NULL; for (i = 0, opt = ctx->dhcp6_opts; i < ctx->dhcp6_opts_len; i++, opt++) { |