From 341465c660657f4753477290af86a386e4962c7b Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sat, 7 May 2016 21:25:02 +0000 Subject: [PATCH] Fix option concatenation. --- dhcp.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/dhcp.c b/dhcp.c index 69a030e2..e0afcabe 100644 --- a/dhcp.c +++ b/dhcp.c @@ -213,11 +213,7 @@ get_option(struct dhcpcd_ctx *ctx, if (o == opt) { if (op) { /* We must concatonate the options. */ - if ((bp && ctx->opt_buffer && - (size_t)(bp - ctx->opt_buffer) + ol > - ctx->opt_buffer_len) || - ol > ctx->opt_buffer_len) - { + if (bl + l > ctx->opt_buffer_len) { size_t pos; uint8_t *nb; @@ -226,12 +222,11 @@ get_option(struct dhcpcd_ctx *ctx, (bp - ctx->opt_buffer); else pos = 0; - nb = realloc(ctx->opt_buffer, - ctx->opt_buffer_len + ol); + nb = realloc(ctx->opt_buffer, bl + l); if (nb == NULL) return NULL; ctx->opt_buffer = nb; - ctx->opt_buffer_len += ol; + ctx->opt_buffer_len = bl + l; bp = ctx->opt_buffer + pos; } if (bp == NULL) -- 2.47.3