Skip to content

Commit 07b108a

Browse files
Potential fix for code scanning alert no. 12: Potentially overflowing call to snprintf
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 5cb357c commit 07b108a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

applications/zpc/components/zpc_utils/src/zpc_converters.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ sl_status_t zpc_converters_dsk_to_str(const zwave_dsk_t src,
5252
size_t index = 0;
5353
for (int i = 0; i < sizeof(zwave_dsk_t); i += 2) {
5454
int d = (src[i] << 8) | src[i + 1];
55-
index += snprintf(&dst[index], dst_max_len - index, "%05i-", d);
55+
int n = snprintf(&dst[index], dst_max_len - index, "%05i-", d);
56+
if (n < 0 || n >= dst_max_len - index) {
57+
return SL_STATUS_WOULD_OVERFLOW;
58+
}
59+
index += n;
5660
}
5761
// Erase the last "-"
5862
if (index > 0) {

0 commit comments

Comments
 (0)