Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Replace use of strcpy by memcpy on String::concat(const char*,uint32_t) ? #590

Closed
@rwsalie

Description

Hello Arduino Core Teams,

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /