aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2023-09-12 05:08:11 +0000
committerCy Schubert <cy@FreeBSD.org>2023-09-15 14:07:43 +0000
commit7233b4d8b95baff0f2f2915a8e93a5df2b6e5c4b (patch)
tree0388db949b966bfcde0b5fee025fc2b030aa1213
parentae8d4ec2e19eb6e6c9f917fd23dbda7d92e6708f (diff)
downloadports-7233b4d8b95baff0f2f2915a8e93a5df2b6e5c4b.tar.gz
ports-7233b4d8b95baff0f2f2915a8e93a5df2b6e5c4b.zip
security/wpa_supplicant-devel: Reapply c586ac04eb66
Reapply "Fix 100% CPU when USB wlan NIC removed." hostapd calls pcap_next(3) to read the next packet off the wlan interface. pcap_next() returns a pointer to the packet header but does not indicate success or failure. Unfortunately this results in an infinite loop (100% CPU) when the wlan device disappears, i.e. when a USB wlan device is manually removed or a USB error results in the device removal. However pcap_next_ex(3) does return success or failure. To resolve this we use pcap_next_ex(), forcing hostapd to exit when the error is encountered. An error message is printed to syslog or stderr when debugging (-d flag) is enabled. Unfortunately wpa_printf() only works when debugging is enabled. PR: 253608, 273696 Obtained from: src 6e5d01124fd4 Reported by: Damjan Jovanovic <damjan.jov@gmail.com>, bz (privately) (cherry picked from commit 5da13f40eeaa4b39b3a9fd41e58d082e954acce6)
-rw-r--r--security/wpa_supplicant-devel/Makefile2
-rw-r--r--security/wpa_supplicant-devel/files/patch-src_l2__packet_l2__packet__freebsd.c16
2 files changed, 15 insertions, 3 deletions
diff --git a/security/wpa_supplicant-devel/Makefile b/security/wpa_supplicant-devel/Makefile
index 7fc017f967bf..d28ed3db5b82 100644
--- a/security/wpa_supplicant-devel/Makefile
+++ b/security/wpa_supplicant-devel/Makefile
@@ -1,6 +1,6 @@
PORTNAME= wpa_supplicant
PORTVERSION= ${COMMIT_DATE}
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= security net
PKGNAMESUFFIX= -devel
diff --git a/security/wpa_supplicant-devel/files/patch-src_l2__packet_l2__packet__freebsd.c b/security/wpa_supplicant-devel/files/patch-src_l2__packet_l2__packet__freebsd.c
index e256ee3860e1..62365bdc9900 100644
--- a/security/wpa_supplicant-devel/files/patch-src_l2__packet_l2__packet__freebsd.c
+++ b/security/wpa_supplicant-devel/files/patch-src_l2__packet_l2__packet__freebsd.c
@@ -1,5 +1,5 @@
---- src/l2_packet/l2_packet_freebsd.c.orig 2022-01-16 12:51:29.000000000 -0800
-+++ src/l2_packet/l2_packet_freebsd.c 2022-04-14 07:23:26.534960000 -0700
+--- src/l2_packet/l2_packet_freebsd.c.orig 2023-09-05 10:38:47.000000000 -0700
++++ src/l2_packet/l2_packet_freebsd.c 2023-09-11 22:06:24.154851000 -0700
@@ -8,7 +8,10 @@
*/
@@ -12,3 +12,15 @@
#include <net/bpf.h>
#endif /* __APPLE__ */
#include <pcap.h>
+@@ -82,7 +85,10 @@
+ unsigned char *buf;
+ size_t len;
+
+- packet = pcap_next(pcap, &hdr);
++ if (pcap_next_ex(pcap, &hdr, &packet) == -1) {
++ wpa_printf(MSG_ERROR, "Error reading packet, has device disappeared?");
++ eloop_terminate();
++ }
+
+ if (!l2->rx_callback || !packet || hdr.caplen < sizeof(*ethhdr))
+ return;