Hi, thank you for the great work.
I've encountered a seg fault after registering a new uri. The issue seems to related to memcpy of response_string. I think the 3rd argument should be the size of the response string to be copied instead of kMaxBufferSize, or whichever is smaller.
|
response_string = |
|
to_string(http_response, http_request.method() != HttpMethod::HEAD); |
|
memcpy(raw_response->buffer, response_string.c_str(), kMaxBufferSize); |
|
raw_response->length = response_string.length(); |
|
} |
this is a potential fix.
response_string
= to_string (http_response, http_request.method () != HttpMethod::HEAD);
const size_t res_len = response_string.length ();
size_t len_to_copy = (res_len < kMaxBufferSize)
? res_len : kMaxBufferSize;
memmove (raw_response->buffer, response_string.c_str (), len_to_copy);
raw_response->buffer[response_string.length ()] = '\0';
raw_response->length = response_string.length ();
I've forked the project to reproduce my error at this repo.
Hi, thank you for the great work.
I've encountered a seg fault after registering a new uri. The issue seems to related to
memcpyofresponse_string. I think the 3rd argument should be the size of the response string to be copied instead ofkMaxBufferSize, or whichever is smaller.http-server/src/http_server.cc
Lines 238 to 242 in 1c17136
this is a potential fix.
response_string = to_string (http_response, http_request.method () != HttpMethod::HEAD); const size_t res_len = response_string.length (); size_t len_to_copy = (res_len < kMaxBufferSize) ? res_len : kMaxBufferSize; memmove (raw_response->buffer, response_string.c_str (), len_to_copy); raw_response->buffer[response_string.length ()] = '\0'; raw_response->length = response_string.length ();I've forked the project to reproduce my error at this repo.