-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite loop parsing headers (in chrome) #159
Comments
To clarify the issue, this is the "readline" function (in HTTPConnection.cpp):
I think the problem is, if the condition (_bufferProcessed+1 < _bufferUnusedIdx) is false, the program never leaves the while statement. |
I think I've identified the problem more accurately. The "infinite loop" problem happens when "_bufferProcessed=511" and "_bufferUnused=512". You don't need chrome to reproduce the problem. Attached to this file there is the custom headers i've "fabricated" to trigger the infinite loop situation. Run with "curl -H @header_file.txt --insecure https://esp32-ip" |
More information: this is the modified function i've used to identify the bug:
If you put this code into the library (replace the original "readLine" in HTTPConnection.cpp), you will see in the debug messages the values of the variables bufferProcessed and bufferUnused... To trigger the bug, you only have to make sure that at the end of the header line, bufferProcessed is 511. It is easy... you only have to add characters to the last header. I don't know what is the fix, though! |
I faced the same problem and managed to get it fixed. // ===== the updated "readLine" void HTTPConnection::readLine(int lengthLimit) {
} // ===== the updated "case STATE_REQUEST_FINISHED:" section
|
Thanks! I hope the maintainers will fix it. |
Description
When using chrome 99.0.4844.51 (linux) to access the HTTPS server, the microcontroller goes into a infinite loop. It happens when it is parsing the client headers.
How To Reproduce
Steps to reproduce the behavior:
If using curl or wget it works fine. I have checked that in firefox also works.
Expected Behavior
Should respond with the expected html code
Actual Behavior
The response never arrives to the client.
ESP32 Module
Please provide specifications of your module
Software (please complete the following information if applicable)
Possible solution
See patch for "possible" solution. I know it is not the right answer. But when I apply this patch to the code, it works fine in chrome too.
I don't understand where is exactly the problem, i think that is the management of the buffer. Maybe the headers are too long??
HTTPConnection.patch.txt
The text was updated successfully, but these errors were encountered: