Thread (7 messages) 7 messages, 3 authors, 2021-11-26
STALE1651d LANDED

[PATCH v4 3/3] mwifiex: Ensure the version string from the firmware is 0-terminated

From: Jonas Dreßler <hidden>
Date: 2021-11-03 20:18:24
Also in: lkml, netdev
Subsystem: marvell mwifiex wireless driver, the rest · Maintainers: Brian Norris, Linus Torvalds

We assume at a few places that priv->version_str is 0-terminated, but
right now we trust the firmware that this is the case with the version
string we get from it.

Let's rather ensure this ourselves and replace the last character with
'\0'.

Signed-off-by: Jonas Dreßler <redacted>
---
 drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
index 6c7b0b9bc4e9..1a4ae8a42a31 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
@@ -734,6 +734,9 @@ static int mwifiex_ret_ver_ext(struct mwifiex_private *priv,
 		       MWIFIEX_VERSION_STR_LENGTH);
 		memcpy(priv->version_str, ver_ext->version_str,
 		       MWIFIEX_VERSION_STR_LENGTH);
+
+		/* Ensure the version string from the firmware is 0-terminated */
+		priv->version_str[MWIFIEX_VERSION_STR_LENGTH - 1] = '\0';
 	}
 	return 0;
 }
-- 
2.33.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help