ar71xx: another fix to wndr3700_board_detect
authorFelix Fietkau <nbd@openwrt.org>
Sun, 3 Jan 2016 14:48:17 +0000 (14:48 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 3 Jan 2016 14:48:17 +0000 (14:48 +0000)
My last bugfix (r47538) introduced a new bug in wndr3700_board_detect
(again...).

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
directly.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Backport of r48075

SVN-Revision: 48089

target/linux/ar71xx/base-files/lib/ar71xx.sh

index 267e0b6725514538b983faf57ec7d78b43ce6395..0b2857d8b3860a02413b32588640bb293c0ab6e0 100755 (executable)
@@ -39,7 +39,7 @@ wndr3700_board_detect() {
        "33373031")
                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
                $'\xff'*)
                        if [ "${model:24:1}" = 'N' ]; then