* src/cookies.c (parse_set_cookie): Remove use of alloca

This commit is contained in:
Tim Rühsen 2020-02-14 11:48:19 +01:00
parent 8610b0b355
commit 78a848c69a

View File

@ -395,12 +395,15 @@ parse_set_cookie (const char *set_cookie, bool silent)
}
else if (TOKEN_IS (name, "expires"))
{
char *value_copy;
char value_copy[128];
size_t value_len = value.e - value.b;
time_t expires;
if (!TOKEN_NON_EMPTY (value))
if (!TOKEN_NON_EMPTY (value) || value_len >= sizeof (value_copy))
goto error;
BOUNDED_TO_ALLOCA (value.b, value.e, value_copy);
memcpy (value_copy, value.b, value_len);
value_copy[value_len] = 0;
/* Check if expiration spec is valid.
If not, assume default (cookie doesn't expire, but valid only for