Skip to content

Commit

Permalink
Fixed a buffer overflow issue with http calls and emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
tanis2000 committed Sep 8, 2023
1 parent 56610f1 commit 92b037e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/binocle/core/binocle_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ bool binocle_http_get(const char *url, binocle_http_body_t *body) {
body->memory = malloc(1); /* will be grown as needed by the realloc above */
body->size = 0; /* no data at this point */
char *res = do_binocle_http_get(url);
body->memory = SDL_realloc(body->memory, SDL_strlen(res));
body->size = SDL_strlen(res);
body->memory = SDL_realloc(body->memory, SDL_strlen(res) + 1);
body->size = SDL_strlen(res) + 1;
SDL_memcpy(body->memory, res, body->size);
body->memory[body->size - 1] = 0;
free(res);
return 0;
}
Expand Down

0 comments on commit 92b037e

Please sign in to comment.