commit b108fe3

hovercats  ·  2024-03-17 00:11:39 +0000 UTC
parent 0e1a58b
eiwd: add patch for removal of basename() in musl 1.2.5
2 files changed,  +42, -1
+41, -0
 1@@ -0,0 +1,41 @@
 2+From ba5a6df2d170fce96354f0c9ba281fe049d2f0a3 Mon Sep 17 00:00:00 2001
 3+From: Denis Kenzior <denkenz@gmail.com>
 4+Date: Wed, 14 Feb 2024 14:50:06 -0600
 5+Subject: [PATCH] wiphy: Remove basename() use
 6+
 7+basename use is considered harmful.  There are two versions of
 8+basename (see man 3 basename for details).  The more intuitive version,
 9+which is currently being used inside wiphy.c, is not supported by musl
10+libc implementation.  Use of the libgen version is not preferred, so
11+drop use of basename entirely.  Since wiphy.c is the only call site of
12+basename() inside iwd, open code the required logic.
13+---
14+ src/wiphy.c | 5 ++++-
15+ 1 file changed, 4 insertions(+), 1 deletion(-)
16+
17+diff --git a/src/wiphy.c b/src/wiphy.c
18+index 3258b761..0d64b1b3 100644
19+--- a/src/wiphy.c
20++++ b/src/wiphy.c
21+@@ -1896,6 +1896,7 @@ static bool wiphy_get_driver_name(struct wiphy *wiphy)
22+ 	unsigned int j;
23+ 	const struct l_settings *config = iwd_get_config();
24+ 	char **flag_list;
25++	char *driver;
26+ 
27+ 	driver_link = l_strdup_printf("/sys/class/ieee80211/%s/device/driver",
28+ 					wiphy->name);
29+@@ -1907,7 +1908,9 @@ static bool wiphy_get_driver_name(struct wiphy *wiphy)
30+ 	}
31+ 
32+ 	driver_path[len] = '\0';
33+-	wiphy->driver_str = l_strdup(basename(driver_path));
34++
35++	driver = memrchr(driver_path, '/', len);
36++	wiphy->driver_str = l_strdup(driver ? driver + 1 : driver_path);
37+ 
38+ 	for (i = 0; i < L_ARRAY_SIZE(driver_infos); i++)
39+ 		if (!fnmatch(driver_infos[i].prefix, wiphy->driver_str, 0))
40+-- 
41+2.44.0
42+
+1, -1
1@@ -1 +1 @@
2-2.14 r1
3+2.14 r2