[openwrt/openwrt] base-files: fix offset conversion on caldata_patch_data()

LEDE Commits lede-commits at lists.infradead.org
Wed Feb 12 15:33:40 PST 2025


hauke pushed a commit to openwrt/openwrt.git, branch openwrt-24.10:
https://git.openwrt.org/bccab05ac71e9d4ebec321dba997336e7ddff249

commit bccab05ac71e9d4ebec321dba997336e7ddff249
Author: Shiji Yang <yangshiji66 at qq.com>
AuthorDate: Sat Feb 8 15:36:24 2025 +0800

    base-files: fix offset conversion on caldata_patch_data()
    
    `$(( ))` will convert uninitialized variable to "0". If we want to
    use "-n" to check the string length, it's necessary to make sure the
    converted variable is not empty.
    
    Fixes: 652a6677d5fa ("base-files: Add new functions for ath11k caldata")
    Fixes: https://github.com/openwrt/openwrt/issues/17818
    Signed-off-by: Shiji Yang <yangshiji66 at qq.com>
    Link: https://github.com/openwrt/openwrt/pull/17892
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
    (cherry picked from commit 094b6f593fb4943005e13e2f8581e66bb7c2c8cf)
---
 package/base-files/files/lib/functions/caldata.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/lib/functions/caldata.sh b/package/base-files/files/lib/functions/caldata.sh
index 09289728c0..f0fc907aef 100644
--- a/package/base-files/files/lib/functions/caldata.sh
+++ b/package/base-files/files/lib/functions/caldata.sh
@@ -125,8 +125,8 @@ caldata_valid() {
 caldata_patch_data() {
 	local data=$1
 	local data_count=$((${#1} / 2))
-	local data_offset=$(($2))
-	local chksum_offset=$(($3))
+	[ -n "$2" ] && local data_offset=$(($2))
+	[ -n "$3" ] && local chksum_offset=$(($3))
 	local target=$4
 	local fw_data
 	local fw_chksum




More information about the lede-commits mailing list