1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Parse content-length before using it. Fixes NTLM (#27192).

This commit is contained in:
Tony Lewis 2009-08-17 20:47:05 -07:00
parent ba84c1ec98
commit ee1df87dd8
2 changed files with 31 additions and 25 deletions

View File

@ -1,3 +1,9 @@
2009-08-17 Tony Lewis <tlewis@exelana.com>
* http.c (gethttp): Ensure that we parse Content-Length before we
attempt to refer to its value. Without this fix, NTLM support was
completely buggered. #27192
2009-08-09 Michael Baeuerle <michael.baeuerle@gmx.net>
* ftp.c: #include <strings.h> for strcasecmp.

View File

@ -1834,6 +1834,31 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
print_server_response (resp, " ");
}
if (!opt.ignore_length
&& resp_header_copy (resp, "Content-Length", hdrval, sizeof (hdrval)))
{
wgint parsed;
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;
}
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;
}
/* Check for keep-alive related responses. */
if (!inhibit_keep_alive && contlen != -1)
{
@ -2038,31 +2063,6 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
}
}
if (!opt.ignore_length
&& resp_header_copy (resp, "Content-Length", hdrval, sizeof (hdrval)))
{
wgint parsed;
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;
}
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;
}
request_free (req);
hs->statcode = statcode;