Skip to content

Error parsing HTTP POST parameters bug in srv/WebRequest.cpp (with text/plain content-type) #279

@igorfi

Description

@igorfi

Platform

ESP32

IDE / Tooling

Arduino (IDE/CLI)

What happened?

Parsing of received HTTP POST parameters is incorrectly processed.

I found the error specifically in src/WebRequest.cpp where the followed macro is used.

#define __is_param_char(c) ((c) && ((c) != '{') && ((c) != '[') && ((c) != '&') && ((c) != '='))

This macro is fine, but the parameter inserted into the macro is used inappropriately in this case, because when this parameter is used in the macro 5 times, the variable i is always increased by +5 instead of +1.

This is where it's used incorrectly:

while (i < len && __is_param_char(((char *)buf)[i++]));

Correctly used, it should be like this

char ch; do {ch = ((char *)buf)[i];} while (i++ < len && __is_param_char(ch));

Stack Trace

POST parameters not found

Minimal Reproductible Example (MRE)

.

I confirm that:

  • I have read the documentation.
  • I have searched for similar discussions.
  • I have searched for similar issues.
  • I have looked at the examples.
  • I have upgraded to the lasted version of ESPAsyncWebServer (and AsyncTCP for ESP32).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions