]> sjero.net Git - wget/commitdiff
[svn] Fix crash with --no-cookies.
authorhniksic <devnull@localhost>
Wed, 22 Jun 2005 01:06:48 +0000 (18:06 -0700)
committerhniksic <devnull@localhost>
Wed, 22 Jun 2005 01:06:48 +0000 (18:06 -0700)
src/ChangeLog
src/http.c

index 01401296a071d480365f9bf572ad6602573882d0..927be7246b65b7fdaddefa4ad38f94a110e52953 100644 (file)
@@ -1,3 +1,10 @@
+2005-06-22  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * http.c (gethttp): Only handle --set-cookies (and assert that
+       cookie jar exists) if opt.cookies is true.  Failure to do so
+       triggered the assert when --no-cookies was used and the server
+       sent a Set-Cookie header.  Ouch!
+
 2005-06-22  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * connect.c (select_fd): Expect select() to exist.
index 06c3c5bdafcab564cde2d60d0b088b36e41b68f3..007f0096c996206a40951d2e1ad399411f241646 100644 (file)
@@ -1704,29 +1704,30 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
   hs->remote_time = resp_header_strdup (resp, "Last-Modified");
 
   /* Handle (possibly multiple instances of) the Set-Cookie header. */
-  {
-    char *pth = NULL;
-    int scpos;
-    const char *scbeg, *scend;
-    /* The jar should have been created by now. */
-    assert (wget_cookie_jar != NULL);
-    for (scpos = 0;
-        (scpos = resp_header_locate (resp, "Set-Cookie", scpos,
-                                     &scbeg, &scend)) != -1;
-        ++scpos)
-      {
-       char *set_cookie; BOUNDED_TO_ALLOCA (scbeg, scend, set_cookie);
-       if (pth == NULL)
-         {
-           /* u->path doesn't begin with /, which cookies.c expects. */
-           pth = (char *) alloca (1 + strlen (u->path) + 1);
-           pth[0] = '/';
-           strcpy (pth + 1, u->path);
-         }
-       cookie_handle_set_cookie (wget_cookie_jar, u->host, u->port, pth,
-                                 set_cookie);
-      }
-  }
+  if (opt.cookies)
+    {
+      char *pth = NULL;
+      int scpos;
+      const char *scbeg, *scend;
+      /* The jar should have been created by now. */
+      assert (wget_cookie_jar != NULL);
+      for (scpos = 0;
+          (scpos = resp_header_locate (resp, "Set-Cookie", scpos,
+                                       &scbeg, &scend)) != -1;
+          ++scpos)
+       {
+         char *set_cookie; BOUNDED_TO_ALLOCA (scbeg, scend, set_cookie);
+         if (pth == NULL)
+           {
+             /* u->path doesn't begin with /, which cookies.c expects. */
+             pth = (char *) alloca (1 + strlen (u->path) + 1);
+             pth[0] = '/';
+             strcpy (pth + 1, u->path);
+           }
+         cookie_handle_set_cookie (wget_cookie_jar, u->host, u->port, pth,
+                                   set_cookie);
+       }
+    }
 
   if (resp_header_copy (resp, "Content-Range", hdrval, sizeof (hdrval)))
     {