aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorAdrian Schmutzler <freifunk@adrianschmutzler.de>2019-09-18 13:56:13 +0200
committerChristian Lamparter <chunkeey@gmail.com>2019-09-29 00:46:13 +0200
commit0aab49d234b15545650cb3b6cb49429a0b7b2407 (patch)
tree29d589f7e1d01d6e72de83d4ea78e02932ce8e5d /target/linux
parentc5b4fa20fadbdc47264a9c1f76d7b9351c42e7ec (diff)
downloadupstream-0aab49d234b15545650cb3b6cb49429a0b7b2407.tar.gz
upstream-0aab49d234b15545650cb3b6cb49429a0b7b2407.tar.bz2
upstream-0aab49d234b15545650cb3b6cb49429a0b7b2407.zip
treewide: fix hex2dec conversion for MAC address checksum offset
If chksum_offset is converted by $(($...)) at the beginning, the check [ -n "$chksum_offset" ] will always return true, as the conversion yields "0" for an empty argument, and [ -n "0" ] is true. With this patch, the variable is not converted before the check, but only when it's used in dd. No conversion is done for use in hexdump, as this can deal with hex value offsets. Fixes: b133e466b08e ("treewide: convert WiFi caldata size and offset to hexadecimal") Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom4
-rw-r--r--target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom4
2 files changed, 4 insertions, 4 deletions
diff --git a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index 25d82a5f0d..7911d0aa1e 100644
--- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -60,7 +60,7 @@ xor() {
ath9k_patch_fw_mac() {
local mac=$1
local mac_offset=$(($2))
- local chksum_offset=$(($3))
+ local chksum_offset=$3
local xor_mac
local xor_fw_mac
local xor_fw_chksum
@@ -78,7 +78,7 @@ ath9k_patch_fw_mac() {
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
- dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
+ dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$(($chksum_offset)) count=2
}
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=$mac_offset count=1
diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
index 82f6885221..6f133c82a7 100644
--- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
+++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
@@ -103,7 +103,7 @@ ath9k_patch_fw_mac_crc() {
ath9k_patch_fw_mac() {
local mac=$1
local mac_offset=$(($2))
- local chksum_offset=$(($3))
+ local chksum_offset=$3
local xor_mac
local xor_fw_mac
local xor_fw_chksum
@@ -121,7 +121,7 @@ ath9k_patch_fw_mac() {
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
- dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$chksum_offset count=2
+ dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$(($chksum_offset)) count=2
}
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$mac_offset count=6