]> sjero.net Git - wget/commitdiff
[svn] Fix for bug #20512: Don't abort for negative Content-Length values.
authormicah <devnull@localhost>
Tue, 31 Jul 2007 22:39:52 +0000 (15:39 -0700)
committermicah <devnull@localhost>
Tue, 31 Jul 2007 22:39:52 +0000 (15:39 -0700)
src/ChangeLog
src/http.c

index 852469800035395ad0d33a0193703abdb4bc34a3..ee120fc0c2c03cb38ba08b2fb07c1a7e2fcbafd3 100644 (file)
@@ -1,3 +1,9 @@
+2007-07-31  Micah Cowan  <micah@cowan.name>
+
+       * http.c (gethttp): Set contlen = -1 when we encounter a
+       negative-valued Content-Length header, so we don't consider it
+       an internal error later on and call abort().
+
 2007-07-29  Micah Cowan  <micah@cowan.name>
 
        * url.h, url.c (url_string): Replaced bool arg of the url_string
index e6f266a307a8ce668517d80e0fc5fba048cad70b..26342593ac582c381c37a3988da34046e8204ca9 100644 (file)
@@ -1899,12 +1899,20 @@ File `%s' already there; not retrieving.\n\n"), hs->local_file);
       errno = 0;
       parsed = str_to_wgint (hdrval, NULL, 10);
       if (parsed == WGINT_MAX && errno == ERANGE)
-        /* Out of range.
-           #### If Content-Length is out of range, it most likely
-           means that the file is larger than 2G and that we're
-           compiled without LFS.  In that case we should probably
-           refuse to even attempt to download the file.  */
-        contlen = -1;
+        {
+          /* Out of range.
+             #### If Content-Length is out of range, it most likely
+             means that the file is larger than 2G and that we're
+             compiled without LFS.  In that case we should probably
+             refuse to even attempt to download the file.  */
+          contlen = -1;
+        }
+      else if (parsed < 0)
+        {
+          /* Negative Content-Length; nonsensical, so we can't
+             assume any information about the content to receive. */
+          contlen = -1;
+        }
       else
         contlen = parsed;
     }