X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fcookies.c;h=7f5ba96290cab3c583678c90fd482c02f96a741b;hp=a10971ca86e35fc09ccfc2436e6227224610c64c;hb=8624553a31b148f9051cc11725bc01d9760fa07b;hpb=0aa3c5d33c5faa8902fa638c36314deae45460f3 diff --git a/src/cookies.c b/src/cookies.c index a10971ca..7f5ba962 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -95,7 +95,7 @@ struct cookie { int port; /* port number */ char *path; /* path prefix of the cookie */ - unsigned discard_requested :1; /* whether cookie was created to + unsigned discard_requested :1;/* whether cookie was created to request discarding another cookie. */ @@ -346,7 +346,7 @@ parse_set_cookie (const char *set_cookie, bool silent) struct cookie *cookie = cookie_new (); param_token name, value; - if (!extract_param (&ptr, &name, &value, ';')) + if (!extract_param (&ptr, &name, &value, ';', NULL)) goto error; if (!value.b) goto error; @@ -360,7 +360,7 @@ parse_set_cookie (const char *set_cookie, bool silent) cookie->attr = strdupdelim (name.b, name.e); cookie->value = strdupdelim (value.b, value.e); - while (extract_param (&ptr, &name, &value, ';')) + while (extract_param (&ptr, &name, &value, ';', NULL)) { if (TOKEN_IS (name, "domain")) { @@ -393,7 +393,7 @@ parse_set_cookie (const char *set_cookie, bool silent) /* Check if expiration spec is valid. If not, assume default (cookie doesn't expire, but valid only for - this session.) */ + this session.) */ expires = http_atotm (value_copy); if (expires != (time_t) -1) { @@ -460,9 +460,9 @@ parse_set_cookie (const char *set_cookie, bool silent) #define REQUIRE_DIGITS(p) do { \ - if (!c_isdigit (*p)) \ + if (!c_isdigit (*p)) \ return false; \ - for (++p; c_isdigit (*p); p++) \ + for (++p; c_isdigit (*p); p++) \ ; \ } while (0) @@ -673,9 +673,6 @@ cookie_handle_set_cookie (struct cookie_jar *jar, if (!cookie->domain) { - copy_domain: - /* If the domain was not provided, we use the one we're talking - to, and set exact match. */ cookie->domain = xstrdup (host); cookie->domain_exact = 1; /* Set the port, but only if it's non-default. */ @@ -687,11 +684,12 @@ cookie_handle_set_cookie (struct cookie_jar *jar, if (!check_domain_match (cookie->domain, host)) { logprintf (LOG_NOTQUIET, - _("Cookie coming from %s attempted to set domain to %s\n"), - quotearg_style (escape_quoting_style, host), + _("Cookie coming from %s attempted to set domain to "), + quotearg_style (escape_quoting_style, host)); + logprintf (LOG_NOTQUIET, + _("%s\n"), quotearg_style (escape_quoting_style, cookie->domain)); - xfree (cookie->domain); - goto copy_domain; + cookie->discard_requested = true; } } @@ -1131,7 +1129,9 @@ domain_port (const char *domain_b, const char *domain_e, void cookie_jar_load (struct cookie_jar *jar, const char *file) { - char *line; + char *line = NULL; + size_t bufsize = 0; + FILE *fp = fopen (file, "r"); if (!fp) { @@ -1139,9 +1139,10 @@ cookie_jar_load (struct cookie_jar *jar, const char *file) quote (file), strerror (errno)); return; } + cookies_now = time (NULL); - for (; ((line = read_whole_line (fp)) != NULL); xfree (line)) + while (getline (&line, &bufsize, fp) > 0) { struct cookie *cookie; char *p = line; @@ -1235,6 +1236,8 @@ cookie_jar_load (struct cookie_jar *jar, const char *file) abort_cookie: delete_cookie (cookie); } + + xfree(line); fclose (fp); } @@ -1374,7 +1377,7 @@ test_cookies (void) param_token name, value; const char *ptr = data; int j = 0; - while (extract_param (&ptr, &name, &value, ';')) + while (extract_param (&ptr, &name, &value, ';', NULL)) { char *n = strdupdelim (name.b, name.e); char *v = strdupdelim (value.b, value.e);