diff --git a/common/socket_helper.c b/common/socket_helper.c index 897edf5..886c8d2 100644 --- a/common/socket_helper.c +++ b/common/socket_helper.c @@ -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) {