Fix buffer overrun in content length usage
This commit is contained in:
parent
74d23ebebe
commit
b500327969
|
@ -136,7 +136,7 @@ static char *read_body_by_content_length(int socket_fd, long content_length) {
|
|||
int bytes_read = 0;
|
||||
int write_offset = 0;
|
||||
while ((total_bytes_read += bytes_read = read(socket_fd, buffer, content_length)) <= content_length && bytes_read > 0) {
|
||||
memcpy(result + write_offset, buffer, content_length);
|
||||
memcpy(result + write_offset, buffer, bytes_read);
|
||||
write_offset += bytes_read;
|
||||
// If we've read exactly the number of bytes we need to, we don't need to wait for more data.
|
||||
if (total_bytes_read == content_length) {
|
||||
|
|
Loading…
Reference in a new issue