From 0bc0729bcce0d7cc050747cb0feca5896cf4794e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Thu, 13 Feb 2020 15:40:48 +0100 Subject: [PATCH] * src/http.c (gethttp): Remove use of alloca --- src/http.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/http.c b/src/http.c index d0667284..70caf9d0 100644 --- a/src/http.c +++ b/src/http.c @@ -3509,9 +3509,22 @@ gethttp (const struct url *u, struct url *original_url, struct http_stat *hs, &scbeg, &scend)) != -1; ++scpos) { - char *set_cookie; BOUNDED_TO_ALLOCA (scbeg, scend, set_cookie); + char buf[1024], *set_cookie; + size_t len = scend - scbeg; + + if (len < sizeof (buf)) + set_cookie = buf; + else + set_cookie = xmalloc (len + 1); + + memcpy (set_cookie, scbeg, len); + set_cookie[len] = 0; + cookie_handle_set_cookie (wget_cookie_jar, u->host, u->port, u->path, set_cookie); + + if (set_cookie != buf) + xfree (set_cookie); } }