ar71xx: tplink_pharos_get_model_string: process model before returning it
authorAlexander Couzens <lynxis@fe80.eu>
Fri, 13 Oct 2017 02:17:07 +0000 (04:17 +0200)
committerAlexander Couzens <lynxis@fe80.eu>
Sat, 14 Oct 2017 05:00:48 +0000 (07:00 +0200)
Limits the model string to 64 chars.
Filter out \r\0 chars.

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/base-files/lib/upgrade/platform.sh

index 0bd96c06512f387b395532d127c73d9b4ed40be0..0b3645f5cfa3936a443d527b29a77bcaaed0e5e5 100755 (executable)
@@ -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%%\(*}"
index 65d90d40090bc0019636a8ad71501676dfb37b22..1ffd1bde423de05781ae9f4bb72733b8e92dc09e 100755 (executable)
@@ -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)"