esp32_https_server icon indicating copy to clipboard operation
esp32_https_server copied to clipboard

Fix infinite loop when the buffer ends with \r

Open vvigilante opened this issue 4 years ago • 0 comments

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.

vvigilante avatar Apr 19 '21 15:04 vvigilante