Skip to content

Commit 87eb31c

Browse files
Merge pull request #101 from willmmiles/json-content-length
Discard bytes after Content-Length
2 parents 5418d3e + 464346b commit 87eb31c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/WebRequest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ void AsyncWebServerRequest::_onData(void *buf, size_t len) {
167167
// A handler should be already attached at this point in _parseLine function.
168168
// If handler does nothing (_onRequest is NULL), we don't need to really parse the body.
169169
const bool needParse = _handler && !_handler->isRequestHandlerTrivial();
170+
// Discard any bytes after content length; handlers may overrun their buffers
171+
len = std::min(len, _contentLength - _parsedLength);
170172
if (_isMultipart) {
171173
if (needParse) {
172174
size_t i;

0 commit comments

Comments
 (0)