esp8266 / esp8266/Arduino

In WString.cpp some of the methods access the insecure version of strcmp and strcnmp

Open
#9,269 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

1.In brief: in the String class of the WString.cpp library, the following method responses access string comparison functions (`strcmp()` and `strcnmp()`) that are not ESP8266-safe:
- `bool String::endsWith(const String &s2) const`;
- `bool String::equals(const char *cstr) const`;
- `int String::compareTo(const String &s) const`;
- `bool String::startsWith(const String &s2, unsigned int offset) const`.

2.Problem description: because the listed methods use functions that cannot work with strings in external ROM, an exception (3) occurs when working with the specified methods for strings declared as `F()` or `PSTR()`.

3.An example that will result in exception (3): `if(someString.equals(PSTR("eqString")) {// todo something}` >>> exception (3): in console log.

4.Solution: replace `strcmp()` with `strcmp_P()`, `strcnmp()` with `strcnmp_P()`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.