From e69a032f202a2239801ae065a135ab8e372f827d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E6=98=95?= Date: Thu, 20 Oct 2022 19:26:37 +0800 Subject: [PATCH] dhcpc:fix xid error clear bug. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 田昕 --- netutils/dhcpc/dhcpc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/netutils/dhcpc/dhcpc.c b/netutils/dhcpc/dhcpc.c index 989332f73..eb5be2f43 100644 --- a/netutils/dhcpc/dhcpc.c +++ b/netutils/dhcpc/dhcpc.c @@ -532,6 +532,10 @@ FAR void *dhcpc_open(FAR const char *interface, FAR const void *macaddr, pdhcpc = malloc(sizeof(struct dhcpc_state_s) + maclen - 1); if (pdhcpc) { + /* Initialize the allocated structure */ + + memset(pdhcpc, 0, sizeof(struct dhcpc_state_s)); + /* RFC2131: A DHCP client MUST choose 'xid's in such a * way as to minimize the chance of using an 'xid' identical to one * used by another client. @@ -547,9 +551,6 @@ FAR void *dhcpc_open(FAR const char *interface, FAR const void *macaddr, } } - /* Initialize the allocated structure */ - - memset(pdhcpc, 0, sizeof(struct dhcpc_state_s)); pdhcpc->interface = interface; pdhcpc->maclen = maclen; memcpy(pdhcpc->macaddr, macaddr, pdhcpc->maclen);