Skip to content
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

Fix infinite loop when the buffer ends with \r #123

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vvigilante
Copy link

@vvigilante vvigilante commented Apr 19, 2021

HTTPConnection::readLine has an infinite loop condition, when \r is the last character on the buffer, _bufferProcessed never gets updated, so the exit condition for the loop is never met.

With the modification in the first commit, the \r character gets accounted on its own and the buffer can be refreshed.
The downside is that the \n character will be considered on its own on the next iteration, and added to the _pareserLine.text rather than being grouped with \r and being counted as line terminator.

In the second commit, we keep track of the partial termination using a member variable, so as to detect the \r\n pair even when it happens across two different buffers, so that every problem with the first commit is resolved.

amandel added a commit to openbikesensor/OpenBikeSensorFirmware that referenced this pull request Jun 12, 2021
khoih-prog added a commit to khoih-prog/ESP32_HTTPS_Server that referenced this pull request Sep 27, 2022
Merge some upstream PRs

- Handling of errors - like unstable network - coming via SSL fhessel#89
- WIP: Prevent crash on WebSocket request to non-WebSocket node. fhessel#106
- Fix infinite loop when the buffer ends with \r fhessel#123
- Fixed memory leak in the Websocket example fhessel#157
This was referenced Sep 27, 2022
khoih-prog added a commit to khoih-prog/ESP32_HTTPS_Server that referenced this pull request Sep 27, 2022
1. Merge some upstream PRs

- Handling of errors - like unstable network - coming via SSL fhessel#89
- WIP: Prevent crash on WebSocket request to non-WebSocket node. fhessel#106
- Fix infinite loop when the buffer ends with \r fhessel#123
- Fixed memory leak in the Websocket example fhessel#157

2. Update examples and `README.md`
khoih-prog added a commit to khoih-prog/ESP32_HTTPS_Server that referenced this pull request Sep 27, 2022
1. Merge some upstream PRs

- Handling of errors - like unstable network - coming via SSL fhessel#89
- WIP: Prevent crash on WebSocket request to non-WebSocket node. fhessel#106
- Fix infinite loop when the buffer ends with \r fhessel#123
- Fixed memory leak in the Websocket example fhessel#157

2. Update examples and `README.md`
khoih-prog added a commit to khoih-prog/ESP32_HTTPS_Server that referenced this pull request Sep 27, 2022
1. Merge some upstream PRs

- Handling of errors - like unstable network - coming via SSL fhessel#89
- WIP: Prevent crash on WebSocket request to non-WebSocket node. fhessel#106
- Fix infinite loop when the buffer ends with \r fhessel#123
- Fixed memory leak in the Websocket example fhessel#157

2. Update examples and `README.md`
gb-123-git added a commit to gb-123-git/esp32_https_server that referenced this pull request Aug 18, 2023
* Fix infinite loop when the buffer ends with \r

* Properly check for end of line across buffers

---------

Co-authored-by: vvigilante <[email protected]>
gb-123-git added a commit to gb-123-git/esp32_https_server that referenced this pull request Aug 18, 2023
* Fix infinite loop when the buffer ends with \r
* Properly check for end of line across buffers
---------
Co-authored-by: vvigilante <[email protected]>
hakuamesan added a commit to hakuamesan/esp32_https_server that referenced this pull request Sep 1, 2023
gb-123-git added a commit to gb-123-git/esp32_https_server that referenced this pull request Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant