From d4a747f0067379e7e995325efdaab03103cd07b1 Mon Sep 17 00:00:00 2001 From: Yi Zhu Date: Tue, 12 Apr 2011 23:09:14 +0300 Subject: [PATCH] bsd: Fix buffer size for routing socket with IPv6 disabled AF_INET6 is not always enabled by default, so use AF_INET instead. In addition, use the old fixed length, 2048, as a failover value if the sysctl fails for any reason. --- src/drivers/driver_bsd.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/drivers/driver_bsd.c b/src/drivers/driver_bsd.c index 5348d0974..dc3e26499 100644 --- a/src/drivers/driver_bsd.c +++ b/src/drivers/driver_bsd.c @@ -575,12 +575,12 @@ rtbuf_len(void) { size_t len; - int mib[6] = {CTL_NET, AF_ROUTE, 0, AF_INET6, NET_RT_DUMP, 0}; + int mib[6] = {CTL_NET, AF_ROUTE, 0, AF_INET, NET_RT_DUMP, 0}; if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) { - wpa_printf(MSG_ERROR, "%s failed: %s\n", __func__, + wpa_printf(MSG_WARNING, "%s failed: %s\n", __func__, strerror(errno)); - return -1; + len = 2048; } return len; @@ -717,8 +717,6 @@ bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx) union wpa_event_data data; len = rtbuf_len(); - if (len < 0) - return; buf = os_malloc(len); if (buf == NULL) { @@ -1156,8 +1154,6 @@ wpa_driver_bsd_event_receive(int sock, void *ctx, void *sock_ctx) int n, len; len = rtbuf_len(); - if (len < 0) - return; buf = os_malloc(len); if (buf == NULL) {