Limits the model string to 64 chars.
Filter out \r\0 chars.
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
# 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%%\(*}"
# 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)"