From 541e4ce07773d135346854925c0e134ecd704497 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Fri, 13 Oct 2017 04:17:07 +0200 Subject: [PATCH] ar71xx: tplink_pharos_get_model_string: process model before returning it Limits the model string to 64 chars. Filter out \r\0 chars. Signed-off-by: Alexander Couzens --- target/linux/ar71xx/base-files/lib/ar71xx.sh | 4 ++-- target/linux/ar71xx/base-files/lib/upgrade/platform.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 0bd96c0651..0b3645f5cf 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -349,11 +349,11 @@ tplink_pharos_get_model_string() { # The returned string will end with \r\n, but we don't remove it here # to simplify matching against it in the sysupgrade image check - dd if=$part bs=1 skip=4360 2>/dev/null | head -n 1 + dd if=$part bs=1 skip=4360 count=64 2>/dev/null | tr -d '\r\0' | head -n 1 } tplink_pharos_board_detect() { - local model_string="$(tplink_pharos_get_model_string | tr -d '\r')" + local model_string="$(tplink_pharos_get_model_string)" local oIFS="$IFS"; IFS=":"; set -- $model_string; IFS="$oIFS" local model="${1%%\(*}" diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index 65d90d4009..1ffd1bde42 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -110,7 +110,7 @@ tplink_pharos_check_image() { # read loop won't be executed at all, it will return true, so the image # is accepted (loading the first 1.5M of a remote image for this check seems # a bit extreme) - dd if="$1" bs=1 skip=1511432 count=1024 2>/dev/null | while read line; do + dd if="$1" bs=1 skip=1511432 count=1024 2>/dev/null | tr -d '\0\xff\r' | while read line; do [ "$line" = "$model_string" ] && break done || { echo "Unsupported image (model not in support-list)" -- 2.30.2