From: Holger Schemel Date: Sat, 1 May 2021 15:12:15 +0000 (+0200) Subject: added allocating memory buffers that are too large for the stack X-Git-Tag: 4.3.0.0~170 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=16927bd0f519a3cf09ff4bb3117a734404090c13;p=rocksndiamonds.git added allocating memory buffers that are too large for the stack --- diff --git a/src/libgame/http.c b/src/libgame/http.c index 74fafb37..30f4c03a 100644 --- a/src/libgame/http.c +++ b/src/libgame/http.c @@ -146,8 +146,11 @@ static boolean SetHTTPResponseBody(struct HttpResponse *response, char *buffer, return TRUE; } -boolean DoHttpRequest(struct HttpRequest *request, - struct HttpResponse *response) +static boolean DoHttpRequestExt(struct HttpRequest *request, + struct HttpResponse *response, + char *send_buffer, + char *recv_buffer, + int max_http_buffer_size) { SDLNet_SocketSet socket_set; TCPsocket socket; @@ -213,10 +216,6 @@ boolean DoHttpRequest(struct HttpRequest *request, request->hostname, (int)strlen(request->body)); - int max_http_buffer_size = MAX_HTTP_HEAD_SIZE + MAX_HTTP_BODY_SIZE; - char send_buffer[max_http_buffer_size + 1]; - char recv_buffer[max_http_buffer_size + 1]; - snprintf(send_buffer, max_http_buffer_size, "%s\r\n%s", request->head, request->body); @@ -276,3 +275,20 @@ boolean DoHttpRequest(struct HttpRequest *request, return TRUE; } + +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); + + boolean success = DoHttpRequestExt(request, response, + send_buffer, recv_buffer, + max_http_buffer_size); + + checked_free(send_buffer); + checked_free(recv_buffer); + + return success; +}