[OpenWrt-Devel] [PATCH] ar71xx: another fix to wndr3700_board_detect

Matthias Schiffer mschiffer at universe-factory.net
Sat Jan 2 18:13:39 EST 2016

My last bugfix (r47538) introduced a new bug in wndr3700_board_detect

Assigning the result of ar71xx_get_mtd_offset_size_format to the model
variable before stripping of garbage using awk will cause all NUL bytes to
be removed before awk is applied, leading to model strings like
"NETGEAR WNDRMACv2NETGEAR", where a NUL byte after the v2 is supposed to
terminate the string.

Fix by calling ar71xx_get_mtd_offset_size_format twice, once piping to awk

Signed-off-by: Matthias Schiffer <mschiffer at universe-factory.net>
Both r47538 and this fix should be applied to CC as well.

 target/linux/ar71xx/base-files/lib/ar71xx.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 61dcbba..678482e 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -39,7 +39,7 @@ wndr3700_board_detect() {
 		model="$(ar71xx_get_mtd_offset_size_format art 41 32 %c)"
 		# Use awk to remove everything unprintable
-		model_stripped="$(echo -n "$model" | LC_CTYPE=C awk -v 'FS=[^[:print:]]' '{print $1; exit}')"
+		model_stripped="$(ar71xx_get_mtd_offset_size_format art 41 32 %c | LC_CTYPE=C awk -v 'FS=[^[:print:]]' '{print $1; exit}')"
 		case $model in
 			if [ "${model:24:1}" = 'N' ]; then
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list