From patchwork Sat Jan 2 23:13:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schiffer X-Patchwork-Id: 562115 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0C9EA14031E for ; Sun, 3 Jan 2016 10:14:17 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 8F1D728BE5F; Sun, 3 Jan 2016 00:13:35 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 1032E2844D2 for ; Sun, 3 Jan 2016 00:13:29 +0100 (CET) X-policyd-weight: using cached result; rate: -7.6 Received: from chaos.universe-factory.net (chaos.universe-factory.net [37.72.148.22]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 3 Jan 2016 00:13:28 +0100 (CET) Received: from avalon.neoraider.dn42 (unknown [IPv6:fd1b:c28a:2fd6::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by chaos.universe-factory.net (Postfix) with ESMTPSA id 4E9991814E6 for ; Sun, 3 Jan 2016 00:13:55 +0100 (CET) From: Matthias Schiffer To: openwrt-devel@lists.openwrt.org Date: Sun, 3 Jan 2016 00:13:39 +0100 Message-Id: X-Mailer: git-send-email 2.6.4 Subject: [OpenWrt-Devel] [PATCH] ar71xx: another fix to wndr3700_board_detect X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" 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 --- 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() { "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