mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-21 14:37:57 +00:00
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: b133e466b0
("treewide: convert WiFi caldata size and offset to hexadecimal")
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
parent
c5b4fa20fa
commit
0aab49d234
@ -60,7 +60,7 @@ xor() {
|
|||||||
ath9k_patch_fw_mac() {
|
ath9k_patch_fw_mac() {
|
||||||
local mac=$1
|
local mac=$1
|
||||||
local mac_offset=$(($2))
|
local mac_offset=$(($2))
|
||||||
local chksum_offset=$(($3))
|
local chksum_offset=$3
|
||||||
local xor_mac
|
local xor_mac
|
||||||
local xor_fw_mac
|
local xor_fw_mac
|
||||||
local xor_fw_chksum
|
local xor_fw_chksum
|
||||||
@ -78,7 +78,7 @@ ath9k_patch_fw_mac() {
|
|||||||
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_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}" | \
|
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
|
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc oflag=seek_bytes bs=6 seek=$mac_offset count=1
|
||||||
|
@ -103,7 +103,7 @@ ath9k_patch_fw_mac_crc() {
|
|||||||
ath9k_patch_fw_mac() {
|
ath9k_patch_fw_mac() {
|
||||||
local mac=$1
|
local mac=$1
|
||||||
local mac_offset=$(($2))
|
local mac_offset=$(($2))
|
||||||
local chksum_offset=$(($3))
|
local chksum_offset=$3
|
||||||
local xor_mac
|
local xor_mac
|
||||||
local xor_fw_mac
|
local xor_fw_mac
|
||||||
local xor_fw_chksum
|
local xor_fw_chksum
|
||||||
@ -121,7 +121,7 @@ ath9k_patch_fw_mac() {
|
|||||||
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_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}" | \
|
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
|
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 seek=$mac_offset count=6
|
||||||
|
Loading…
Reference in New Issue
Block a user