]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Ensure offer_len is 0 after making offer NULL.
authorRoy Marples <roy@marples.name>
Sat, 13 Aug 2016 15:11:10 +0000 (15:11 +0000)
committerRoy Marples <roy@marples.name>
Sat, 13 Aug 2016 15:11:10 +0000 (15:11 +0000)
Set offer_len before each memcpy to aid debugging.

dhcp.c

diff --git a/dhcp.c b/dhcp.c
index b03d66ec2dcba46396268baef7889838939c982e..8b4b263a61ae799bf3a9feb9b685b25c9f4363d5 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -2398,6 +2398,7 @@ dhcp_inform(struct interface *ifp)
        state->state = DHS_INFORM;
        free(state->offer);
        state->offer = NULL;
+       state->offer_len = 0;
 
        if (ifo->req_addr.s_addr == INADDR_ANY) {
                ia = ipv4_iffindaddr(ifp, NULL, NULL);
@@ -2973,8 +2974,8 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
                                return;
                        }
                }
-               memcpy(state->offer, bootp, bootp_len);
                state->offer_len = bootp_len;
+               memcpy(state->offer, bootp, bootp_len);
                bootp_copied = true;
                if (ifp->ctx->options & DHCPCD_TEST) {
                        free(state->old);
@@ -3051,8 +3052,8 @@ rapidcommit:
                                return;
                        }
                }
-               memcpy(state->offer, bootp, bootp_len);
                state->offer_len = bootp_len;
+               memcpy(state->offer, bootp, bootp_len);
        }
 
        lease->frominfo = 0;
@@ -3436,6 +3437,7 @@ dhcp_start1(void *arg)
        clock_gettime(CLOCK_MONOTONIC, &state->started);
        free(state->offer);
        state->offer = NULL;
+       state->offer_len = 0;
 
        if (state->arping_index < ifo->arping_len) {
                struct arp_state *astate;
@@ -3492,6 +3494,7 @@ dhcp_start1(void *arg)
                        {
                                free(state->offer);
                                state->offer = NULL;
+                               state->offer_len = 0;
                        }
                }
        }