mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-19 07:55:54 +00:00
HTTP Server : Fix for tolerating LF terminated headers
List of changes: * When parsing requests, count termination from LF characters only * Correct memcpy() length parameter in httpd_unrecv() (pointed out by jimparis in GitHub issue thread) * Use ssize_t to store results of length subtractions during parsing * Modify some comments to reduce ambiguity Closes https://github.com/espressif/esp-idf/issues/3182
This commit is contained in:
@@ -155,9 +155,10 @@ size_t httpd_unrecv(struct httpd_req *r, const char *buf, size_t buf_len)
|
||||
/* Truncate if external buf_len is greater than pending_data buffer size */
|
||||
ra->sd->pending_len = MIN(sizeof(ra->sd->pending_data), buf_len);
|
||||
|
||||
/* Copy data into internal pending_data buffer */
|
||||
/* Copy data into internal pending_data buffer with the exact offset
|
||||
* such that it is right aligned inside the buffer */
|
||||
size_t offset = sizeof(ra->sd->pending_data) - ra->sd->pending_len;
|
||||
memcpy(ra->sd->pending_data + offset, buf, buf_len);
|
||||
memcpy(ra->sd->pending_data + offset, buf, ra->sd->pending_len);
|
||||
ESP_LOGD(TAG, LOG_FMT("length = %d"), ra->sd->pending_len);
|
||||
return ra->sd->pending_len;
|
||||
}
|
||||
|
Reference in New Issue
Block a user