Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

uGnssInfoGetVersions: do not crash if partial version data #157

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gnss/src/u_gnss_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down