talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 8c320850024aee644fcb6d4f9ae564abcf1488e9
parent 84af95468c04456d89002ccf42b4fe56d3ce8b0a
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Sun, 27 Jan 2019 11:45:38 +0100

Fix possible stack overflow in vcalendar's Curl data handler

Allocate the VLA on heap instead.

Diffstat:
Msrc/plugins/vcalendar/vcal_folder.c | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/plugins/vcalendar/vcal_folder.c b/src/plugins/vcalendar/vcal_folder.c @@ -1550,17 +1550,20 @@ static size_t curl_recv(void *buf, size_t size, size_t nmemb, void *stream) { struct CBuf *buffer = (struct CBuf *)stream; gchar *tmp = NULL; - gchar tmpbuf[size*nmemb + 1]; + gchar *tmpbuf = g_malloc0(size*nmemb + 1); + + g_return_val_if_fail(tmpbuf != NULL, 0); memcpy(tmpbuf, buf, size*nmemb); - tmpbuf[size*nmemb] = '\0'; if (buffer->str) { + /* If the buffer already has contents, append the new data. */ tmp = g_strconcat(buffer->str, tmpbuf, NULL); + g_free(tmpbuf); g_free(buffer->str); buffer->str = tmp; } else { - buffer->str = g_strdup(tmpbuf); + buffer->str = tmpbuf; } return size*nmemb;