From: Holger Schemel Date: Mon, 18 Apr 2022 21:44:19 +0000 (+0200) Subject: fixed copying HTTP response buffer for Emscripten platform X-Git-Tag: 4.3.2.1^0 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=45ac9197f725f8c6dd8722e780e79cb733615566;p=rocksndiamonds.git fixed copying HTTP response buffer for Emscripten platform --- diff --git a/src/libgame/http.c b/src/libgame/http.c index 333ef2a3..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; }