-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Description
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Problem Description
See line 291 (and line 280):
Arduino/cores/esp8266/WString.cpp
Lines 284 to 293 in eda4e08
| String &String::copy(const __FlashStringHelper *pstr, unsigned int length) { | |
| if (!reserve(length)) { | |
| invalidate(); | |
| return *this; | |
| } | |
| setLen(length); | |
| memcpy_P(wbuffer(), (PGM_P)pstr, length); // We know wbuffer() cannot ever be in PROGMEM, so memcpy safe here | |
| wbuffer()[length] = 0; | |
| return *this; | |
| } |
When allocating an array of N elements, accessing element [N] is out of bounds.
This only happens sometimes at very specific string lengths, as setLen only allocates in multiples of N bytes.
N.B. similar issue for ESP32, so I will also add an issue there.
Suggested fix:
reserve(length + 1);N.B. This function is likely to be called with strlen() or strlen_P() as argument, which does not include the ending null character.
Metadata
Metadata
Assignees
Labels
No labels