Skip to content

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

@gorlov-ai

Description

@gorlov-ai

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().

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