mirror of
https://github.com/mirror/wget.git
synced 2025-03-22 15:50:13 +08:00
* src/cookies.c (cookie_handle_set_cookie): Remove use of alloca
This commit is contained in:
parent
36ccb62e92
commit
f071030659
@ -750,11 +750,20 @@ cookie_handle_set_cookie (struct cookie_jar *jar,
|
|||||||
{
|
{
|
||||||
struct cookie *cookie;
|
struct cookie *cookie;
|
||||||
cookies_now = time (NULL);
|
cookies_now = time (NULL);
|
||||||
|
char buf[1024], *tmp;
|
||||||
|
size_t pathlen = strlen(path);
|
||||||
|
|
||||||
/* Wget's paths don't begin with '/' (blame rfc1808), but cookie
|
/* Wget's paths don't begin with '/' (blame rfc1808), but cookie
|
||||||
usage assumes /-prefixed paths. Until the rest of Wget is fixed,
|
usage assumes /-prefixed paths. Until the rest of Wget is fixed,
|
||||||
simply prepend slash to PATH. */
|
simply prepend slash to PATH. */
|
||||||
PREPEND_SLASH (path);
|
if (pathlen < sizeof (buf) - 1)
|
||||||
|
tmp = buf;
|
||||||
|
else
|
||||||
|
tmp = xmalloc (pathlen + 2);
|
||||||
|
|
||||||
|
*tmp = '/';
|
||||||
|
memcpy (tmp + 1, path, pathlen + 1);
|
||||||
|
path = tmp;
|
||||||
|
|
||||||
cookie = parse_set_cookie (set_cookie, false);
|
cookie = parse_set_cookie (set_cookie, false);
|
||||||
if (!cookie)
|
if (!cookie)
|
||||||
@ -816,11 +825,15 @@ cookie_handle_set_cookie (struct cookie_jar *jar,
|
|||||||
}
|
}
|
||||||
|
|
||||||
store_cookie (jar, cookie);
|
store_cookie (jar, cookie);
|
||||||
|
if (tmp != buf)
|
||||||
|
xfree (tmp);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (cookie)
|
if (cookie)
|
||||||
delete_cookie (cookie);
|
delete_cookie (cookie);
|
||||||
|
if (tmp != buf)
|
||||||
|
xfree (tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Support for sending out cookies in HTTP requests, based on
|
/* Support for sending out cookies in HTTP requests, based on
|
||||||
|
Loading…
Reference in New Issue
Block a user