]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix option concatenation.
authorRoy Marples <roy@marples.name>
Sat, 7 May 2016 21:25:02 +0000 (21:25 +0000)
committerRoy Marples <roy@marples.name>
Sat, 7 May 2016 21:25:02 +0000 (21:25 +0000)
dhcp.c

diff --git a/dhcp.c b/dhcp.c
index 69a030e2459bd769a8ccf3263fe6019627eb9dca..e0afcabe5a3d9be8678e228d015a20d491bb09dd 100644 (file)
--- 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)