X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fhttp.c;h=c83c91f71b1515695da8540a0f7c384b9c4f74ea;hb=HEAD;hp=0064bc14e5e3bdf01001dedfeba1ca1ea16c0c32;hpb=9695a8edd4c617065b02433dd649266e2d154ad3;p=rocksndiamonds.git diff --git a/src/libgame/http.c b/src/libgame/http.c index 0064bc14..c83c91f7 100644 --- a/src/libgame/http.c +++ b/src/libgame/http.c @@ -65,18 +65,18 @@ static void SetHttpResponseToDefaults(struct HttpResponse *response) response->status_text[0] = '\0'; } -struct HttpResponse *GetHttpResponseFromBuffer(void *buffer, int size) +struct HttpResponse *GetHttpResponseFromBuffer(void *buffer, int body_size) { - if (size > MAX_HTTP_BODY_SIZE) + if (body_size > MAX_HTTP_BODY_SIZE) return NULL; struct HttpResponse *response = checked_calloc(sizeof(struct HttpResponse)); SetHttpResponseToDefaults(response); - strncpy(response->body, buffer, MAX_HTTP_BODY_SIZE); - response->body[MAX_HTTP_BODY_SIZE] = '\0'; - response->body_size = MIN(size, MAX_HTTP_BODY_SIZE); + memcpy(response->body, buffer, body_size); + response->body[body_size] = '\0'; + response->body_size = body_size; return response; } @@ -393,9 +393,9 @@ static boolean DoHttpRequestExt(struct HttpRequest *request, boolean DoHttpRequest(struct HttpRequest *request, struct HttpResponse *response) { - int max_http_buffer_size = MAX_HTTP_HEAD_SIZE + MAX_HTTP_BODY_SIZE; - char *send_buffer = checked_malloc(max_http_buffer_size + 1); - char *recv_buffer = checked_malloc(max_http_buffer_size + 1); + int max_http_buffer_size = MAX_HTTP_HEAD_SIZE + 2 + MAX_HTTP_BODY_SIZE + 1; + char *send_buffer = checked_malloc(max_http_buffer_size); + char *recv_buffer = checked_malloc(max_http_buffer_size); SDLNet_SocketSet socket_set = NULL; TCPsocket socket = NULL;