From 1407cb6ac052b02a0d9e5822df164bcb3ea75889 Mon Sep 17 00:00:00 2001 From: Alon Bar-Lev Date: Sun, 5 Nov 2023 01:45:18 +0200 Subject: [PATCH] uGnssInfoGetVersions: do not crash if partial version data Signed-off-by: Alon Bar-Lev --- gnss/src/u_gnss_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnss/src/u_gnss_info.c b/gnss/src/u_gnss_info.c index ae7b73a18..cc287e35f 100644 --- a/gnss/src/u_gnss_info.c +++ b/gnss/src/u_gnss_info.c @@ -144,7 +144,7 @@ int32_t uGnssInfoGetVersions(uDeviceHandle_t gnssHandle, memset(pVer, 0, sizeof(*pVer)); strncpy(pVer->ver, message.sw, sizeof(pVer->ver)); strncpy(pVer->hw, message.hw, sizeof(pVer->hw)); - size_t n = (errorCodeOrLength - sizeof(message.sw) + sizeof(message.hw)) / sizeof(message.ext[0]); + size_t n = (errorCodeOrLength - (sizeof(message.sw) + sizeof(message.hw))) / sizeof(message.ext[0]); for (size_t i = 0; i < n; i++) { if (0 == strncmp(message.ext[i], "ROM BASE ", 9)) { strncpy(pVer->rom, message.ext[i] + 9, sizeof(pVer->rom));