Search Linux Wireless

[PATCH 6/6] ath6kl: properly null terminate the firmware string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The firmware version read from the firmware image is not null terminated and
because of that there were few bytes of garbage after the firmware string:

[10420.164632] ath6kl: ar6004 hw 3.0 usb fw 3.5.0.300-1^A api 4

Add proper null termination to ath6kl_fetch_fw_apin() clean the firmware
version string.

Signed-off-by: Kalle Valo <kvalo@xxxxxxxxxxxxxxxx>
---
 drivers/net/wireless/ath/ath6kl/init.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 3dea97aa9b74..63c0cffd5634 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -942,7 +942,7 @@ static int ath6kl_fetch_fw_api1(struct ath6kl *ar)
 
 static int ath6kl_fetch_fw_apin(struct ath6kl *ar, const char *name)
 {
-	size_t magic_len, len, ie_len;
+	size_t magic_len, len, ie_len, ver_len;
 	const struct firmware *fw;
 	struct ath6kl_fw_ie *hdr;
 	char filename[100];
@@ -993,8 +993,10 @@ static int ath6kl_fetch_fw_apin(struct ath6kl *ar, const char *name)
 
 		switch (ie_id) {
 		case ATH6KL_FW_IE_FW_VERSION:
-			strlcpy(ar->wiphy->fw_version, data,
-				sizeof(ar->wiphy->fw_version));
+			/* the string is not null terminated */
+			ver_len = min(ie_len, sizeof(ar->wiphy->fw_version));
+			memcpy(ar->wiphy->fw_version, data, ver_len);
+			ar->wiphy->fw_version[ver_len] = '\0';
 
 			ath6kl_dbg(ATH6KL_DBG_BOOT,
 				   "found fw version %s\n",

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux