Skip to content

Commit d039d30

Browse files
committed
lwip - Fix lwip_mac_address buffer overflow
Sounds serious, but should be benign. Signed-off-by: Tony Wu <[email protected]>
1 parent 16a8d23 commit d039d30

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

features/FEATURE_LWIP/lwip-interface/lwip_stack.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static void mbed_lwip_socket_callback(struct netconn *nc, enum netconn_evt eh, u
104104
/* TCP/IP and Network Interface Initialisation */
105105
static struct netif lwip_netif;
106106
static bool lwip_dhcp = false;
107-
static char lwip_mac_address[NSAPI_MAC_SIZE] = "\0";
107+
static char lwip_mac_address[NSAPI_MAC_SIZE];
108108

109109
#if !LWIP_IPV4 || !LWIP_IPV6
110110
static bool all_zeros(const uint8_t *p, int len)
@@ -309,13 +309,13 @@ static void mbed_lwip_netif_status_irq(struct netif *lwip_netif)
309309
static void mbed_lwip_set_mac_address(void)
310310
{
311311
#if (MBED_MAC_ADDRESS_SUM != MBED_MAC_ADDR_INTERFACE)
312-
snprintf(lwip_mac_address, 19, "%02x:%02x:%02x:%02x:%02x:%02x",
312+
snprintf(lwip_mac_address, NSAPI_MAC_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x",
313313
MBED_MAC_ADDR_0, MBED_MAC_ADDR_1, MBED_MAC_ADDR_2,
314314
MBED_MAC_ADDR_3, MBED_MAC_ADDR_4, MBED_MAC_ADDR_5);
315315
#else
316316
char mac[6];
317317
mbed_mac_address(mac);
318-
snprintf(lwip_mac_address, 19, "%02x:%02x:%02x:%02x:%02x:%02x",
318+
snprintf(lwip_mac_address, NSAPI_MAC_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x",
319319
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
320320
#endif
321321
}

0 commit comments

Comments
 (0)