Преглед изворни кода

base-files: enable get_mac_ascii() to handle redundant strings

The function get_mac_ascii() will fail when there are two or more
same MAC address variable names in the mtd partition. Only retain
the first variable to workaround this rare situation.

Fixes: https://github.com/openwrt/openwrt/issues/17236
Signed-off-by: Shiji Yang <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/17262
Signed-off-by: Hauke Mehrtens <[email protected]>
(cherry picked from commit 3410ad2f40c085e5db7a71f6ae4b80734826a1e3)
Shiji Yang пре 1 година
родитељ
комит
676dfd1363
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      package/base-files/files/lib/functions/system.sh

+ 1 - 1
package/base-files/files/lib/functions/system.sh

@@ -66,7 +66,7 @@ get_mac_ascii() {
 	local key="$2"
 	local mac_dirty
 
-	mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p')
+	mac_dirty=$(strings "$part" | sed -n 's/^'"$key"'=//p' | head -n 1)
 
 	# "canonicalize" mac
 	[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"