This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 6b7f9619f0e arch/arm: nrf91: bound modem version parsing
6b7f9619f0e is described below
commit 6b7f9619f0e1e2e541c12fcd3e92e6c393f03b6f
Author: Old-Ding <[email protected]>
AuthorDate: Mon Jul 6 07:34:56 2026 +0800
arch/arm: nrf91: bound modem version parsing
Limit modem version tokens parsed from AT command responses to the LTE
version field sizes. Also require both HWVERSION fields before copying them so
a partial parse does not read an uninitialized temporary buffer.
Signed-off-by: Old-Ding <[email protected]>
---
arch/arm/src/nrf91/nrf91_modem_sock.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/arm/src/nrf91/nrf91_modem_sock.c
b/arch/arm/src/nrf91/nrf91_modem_sock.c
index 4a10e1e9b4d..6208a72aa1e 100644
--- a/arch/arm/src/nrf91/nrf91_modem_sock.c
+++ b/arch/arm/src/nrf91/nrf91_modem_sock.c
@@ -451,20 +451,20 @@ static int nrf91_usrsock_event_callback(int16_t usockid,
uint16_t events)
static int nrf91_modem_getver(lte_version_t *version)
{
- char buffer1[16];
- char buffer2[16];
+ char buffer1[LTE_VER_FIRMWARE_LEN];
+ char buffer2[LTE_VER_NP_PACKAGE_LEN];
int ret = OK;
memset(version, 0, sizeof(*version));
- ret = nrf_modem_at_scanf("AT%HWVERSION", "%%HWVERSION: %s %s",
+ ret = nrf_modem_at_scanf("AT%HWVERSION", "%%HWVERSION: %31s %31s",
buffer1, buffer2);
- if (ret > 0)
+ if (ret == 2)
{
strncpy(version->bb_product, buffer1, LTE_VER_BB_PRODUCT_LEN);
strncpy(version->np_package, buffer2, LTE_VER_NP_PACKAGE_LEN);
}
- ret = nrf_modem_at_scanf("AT+CGMR", "%s", buffer1);
+ ret = nrf_modem_at_scanf("AT+CGMR", "%31s", buffer1);
if (ret > 0)
{
strncpy(version->fw_version, buffer1, LTE_VER_FIRMWARE_LEN);