arduino / arduino/ArduinoCore-samd

Should WString use memcpy not strcpy

Open
#213 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
502
Forks
740
PR merge metrics
No merged PRs in 30d

Description

In WString.cpp (this also applies to avr core)

https://github.com/arduino/ArduinoCore-samd/blob/master/cores/arduino/WString.cpp#L179 and
https://github.com/arduino/ArduinoCore-samd/blob/master/cores/arduino/WString.cpp#L271

strcpy is used, where are length is passed to the copy and concat operation, whereas memcpy should be used so the char* can contain the 0 character.

Contributor guide

No contributing guide indexed for this repository

Research direction

Open WString.cpp and inspect the two referenced locations, lines 179 and 271, along with the corresponding AVR core implementation mentioned in the issue. Verify the copy and concatenation behavior when the source char* contains an embedded zero, and confirm both SAMD and AVR paths handle the provided length correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.