You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can we replace the use of strcpy(2) from String::concat(const char*, uint32_t) by strlcpy(2) or even memcpy ?
Without referencing strcpy(2) on your documentation, if we cast a struct into char*, we could had
a null terminator between the start and the end, and strcpy(2) will never copy at the last char.
unsigned char String::concat(const char *cstr, unsigned int length)
{
unsigned int newlen = len + length;
if (!cstr) return 0;
if (length == 0) return 1;
if (!reserve(newlen)) return 0;
strcpy(buffer + len, cstr);
len = newlen;
return 1;
}
Is it by choice, by using strcpy ?
Edit: The length is not taked care by strcpy, many edge case could resolve into BO
The text was updated successfully, but these errors were encountered:
bilaliscarioth
changed the title
Replace use of strcpy by strlcpy on String::concat(const char*,uint32_t) ?
Replace use of strcpy by memcpy on String::concat(const char*,uint32_t) ?
Jan 16, 2025
Hello Arduino Core Teams,
Can we replace the use of
strcpy
(2) fromString::concat(const char*, uint32_t)
bystrlcpy(2)
or evenmemcpy
?Without referencing
strcpy
(2) on your documentation, if we cast astruct
intochar*
, we could hada null terminator between the start and the end, and
strcpy
(2) will never copy at the last char.Is it by choice, by using
strcpy
?Edit: The length is not taked care by strcpy, many edge case could resolve into BO
The text was updated successfully, but these errors were encountered: