[core] Replace strnlen in buf_append_str for Zephyr compatibility (#15892)

This commit is contained in:
J. Nick Koston
2026-04-21 14:32:29 +02:00
committed by GitHub
parent 947c714f89
commit 1504ac3d19

View File

@@ -1117,7 +1117,10 @@ inline size_t buf_append_str(char *buf, size_t size, size_t pos, const char *str
return size;
}
size_t remaining = size - pos - 1; // reserve space for null terminator
size_t len = strnlen(str, remaining);
size_t len = 0;
while (len < remaining && str[len] != '\0') {
len++;
}
memcpy(buf + pos, str, len);
pos += len;
buf[pos] = '\0';