[openwrt/openwrt] base-files: strip space and tab characters from ASCII mac address

LEDE Commits lede-commits at lists.infradead.org
Sat Jan 4 07:29:47 PST 2025


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/551e04f3c9c063d885ca7a91db36f27f684a3a5c

commit 551e04f3c9c063d885ca7a91db36f27f684a3a5c
Author: Shiji Yang <yangshiji66 at qq.com>
AuthorDate: Mon Dec 16 15:09:50 2024 +0800

    base-files: strip space and tab characters from ASCII mac address
    
    Spaces and tabs are widely used in variable definitions. We have to
    remove them to ensure that get_mac_ascii() works properly.
    
    Signed-off-by: Shiji Yang <yangshiji66 at qq.com>
    Link: https://github.com/openwrt/openwrt/pull/17262
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 package/base-files/files/lib/functions/system.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index aaeb75f261..f43281b5dc 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/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' | head -n 1)
+	mac_dirty=$(strings "$part" | tr -d ' \t' | sed -n 's/^'"$key"'=//p' | head -n 1)
 
 	# "canonicalize" mac
 	[ -n "$mac_dirty" ] && macaddr_canonicalize "$mac_dirty"




More information about the lede-commits mailing list