From dfefb45edf3c4e7ccf8c2a47a3b765128f7c20c4 Mon Sep 17 00:00:00 2001 From: Alexander Dergachev Date: Thu, 10 Apr 2008 22:31:33 +0400 Subject: [PATCH 1/4] aprintf is calling memfatal function now instead of calling abort function for consistency with xmalloc/xrealloc --- src/utils.c | 2 +- src/xmalloc.c | 22 ++++++++++++++++++---- src/xmalloc.h | 7 +++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/utils.c b/src/utils.c index 8c56d4db..3fd1435e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -171,7 +171,7 @@ aprintf (const char *fmt, ...) ret = vasprintf (&str, fmt, args); va_end (args); if (ret < 0 && errno == ENOMEM) - abort (); /* for consistency with xmalloc/xrealloc */ + memfatal ("aprintf", UNKNOWN_ATTEMPTED_SIZE); /* for consistency with xmalloc/xrealloc */ else if (ret < 0) return NULL; return str; diff --git a/src/xmalloc.c b/src/xmalloc.c index 75ecf5ef..aaf743df 100644 --- a/src/xmalloc.c +++ b/src/xmalloc.c @@ -53,15 +53,29 @@ as that of the covered work. */ /* Croak the fatal memory error and bail out with non-zero exit status. */ -static void +void memfatal (const char *context, long attempted_size) { /* Make sure we don't try to store part of the log line, and thus call malloc. */ log_set_save_context (false); - logprintf (LOG_ALWAYS, - _("%s: %s: Failed to allocate %ld bytes; memory exhausted.\n"), - exec_name, context, attempted_size); + + /* We have different log outputs in different situations: + 1) output without bytes information + 2) output with bytes information */ + if (attempted_size == UNKNOWN_ATTEMPTED_SIZE) + { + logprintf (LOG_ALWAYS, + _("%s: %s: Failed to allocate enough memory; memory exhausted.\n"), + exec_name, context); + } + else + { + logprintf (LOG_ALWAYS, + _("%s: %s: Failed to allocate %ld bytes; memory exhausted.\n"), + exec_name, context, attempted_size); + } + exit (1); } diff --git a/src/xmalloc.h b/src/xmalloc.h index 67b97e6e..ce326b1b 100644 --- a/src/xmalloc.h +++ b/src/xmalloc.h @@ -31,6 +31,13 @@ as that of the covered work. */ #ifndef XMALLOC_H #define XMALLOC_H +/* Croak the fatal memory error and bail out with non-zero exit + status. */ +void memfatal (const char *context, long attempted_size); + +/* Constant is using when we don`t know attempted size exactly */ +#define UNKNOWN_ATTEMPTED_SIZE -3 + /* Define this to use Wget's builtin malloc debugging, which is crude but occasionally useful. It will make Wget a lot slower and larger, and susceptible to aborting if malloc_table overflows, so From 8179bb520d21dba6da9eed6493a72972baa6a7a8 Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Thu, 10 Apr 2008 21:35:27 -0700 Subject: [PATCH 2/4] Authentication through proxy. --- tests/ChangeLog | 5 ++++ tests/Makefile.am | 1 + tests/Test-proxy-auth-basic.px | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100755 tests/Test-proxy-auth-basic.px diff --git a/tests/ChangeLog b/tests/ChangeLog index b4e49381..e6972b50 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2008-04-10 Micah Cowan + + * Makefile.in, Test-proxy-auth-basic.px: Added a test for + accessing password-protected URLs through a proxy. + 2008-01-25 Micah Cowan * Makefile.am: Updated copyright year. diff --git a/tests/Makefile.am b/tests/Makefile.am index 61efdd91..224cb9cc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -46,6 +46,7 @@ run-unit-tests: unit-tests$(EXEEXT) ./unit-tests$(EXEEXT) run-px-tests: WgetTest.pm + $(PERLRUN) $(srcdir)/Test-proxy-auth-basic.px && echo && echo $(PERLRUN) $(srcdir)/Test-auth-basic.px && echo && echo $(PERLRUN) $(srcdir)/Test-c-full.px && echo && echo $(PERLRUN) $(srcdir)/Test-c-partial.px && echo && echo diff --git a/tests/Test-proxy-auth-basic.px b/tests/Test-proxy-auth-basic.px new file mode 100755 index 00000000..5566e22f --- /dev/null +++ b/tests/Test-proxy-auth-basic.px @@ -0,0 +1,48 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $wholefile = "You're all authenticated.\n"; + +# code, msg, headers, content +my %urls = ( + '/needs-auth.txt' => { + auth_method => 'Basic', + user => 'fiddle-dee-dee', + passwd => 'Dodgson', + code => "200", + msg => "You want fries with that?", + headers => { + "Content-type" => "text/plain", + }, + content => $wholefile, + }, +); + +my $cmdline = $WgetTest::WGETPATH . " --debug --user=fiddle-dee-dee --password=Dodgson" + . " -e http_proxy=localhost:8080 http://no.such.domain/needs-auth.txt"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( + 'needs-auth.txt' => { + content => $wholefile, + }, +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test-auth-basic", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +exit $the_test->run(); + +# vim: et ts=4 sw=4 + From 9d5b9daf06153f06e46d5c3057993a0195c055e4 Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Fri, 11 Apr 2008 16:28:24 -0700 Subject: [PATCH 3/4] Don't append to an existing .listing when --continue is used. Fixes bug #22825. --- doc/ChangeLog | 5 +++++ doc/wget.texi | 3 +++ src/ChangeLog | 7 +++++++ src/ftp.c | 6 ++++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 343f09f7..c5614d4a 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2008-04-11 Micah Cowan + + * wget.texi : Added Julien Buty, Alexander + Dergachev, and Rabin Vincent. + 2008-03-24 Micah Cowan * wget.texi : Mentioned various caveats in the diff --git a/doc/wget.texi b/doc/wget.texi index cd97bcf0..583c7fcf 100644 --- a/doc/wget.texi +++ b/doc/wget.texi @@ -3770,6 +3770,7 @@ Paul Bludov, Daniel Bodea, Mark Boyns, John Burden, +Julien Buty, Wanderlei Cavassin, Gilles Cedoc, Tim Charron, @@ -3785,6 +3786,7 @@ Andreas Damm, Ahmon Dancy, Andrew Davison, Bertrand Demiddelaer, +Alexander Dergachev, Andrew Deryabin, Ulrich Drepper, Marc Duponcheel, @@ -3938,6 +3940,7 @@ Philipp Thomas, Mauro Tortonesi, Dave Turner, Gisle Vanem, +Rabin Vincent, Russell Vincent, @iftex @v{Z}eljko Vrba, diff --git a/src/ChangeLog b/src/ChangeLog index fddcefd4..23a422d7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -4,6 +4,13 @@ "unknown" value for the attempted allocation size. * utils.c (aprintf): Now calls memfatal, instead of aborting. +2008-04-11 Micah Cowan + + * ftp.c (getftp, ftp_loop_internal): Don't append to an existing + .listing when --continue is used. Fixes bug #22825. Thanks to + Rabin Vincent for pointing the way with a + suggested fix! + 2008-03-19 Micah Cowan * utils.c (test_dir_matches_p): More tests related for diff --git a/src/ftp.c b/src/ftp.c index 115cc5c4..03210321 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -918,7 +918,7 @@ Error in server response, closing control connection.\n")); if (opt.backups) rotate_backups (con->target); - if (restval) + if (restval && !(con->cmd & DO_LIST)) fp = fopen (con->target, "ab"); else if (opt.noclobber || opt.always_rest || opt.timestamping || opt.dirstruct || opt.output_document) @@ -1141,7 +1141,9 @@ ftp_loop_internal (struct url *u, struct fileinfo *f, ccon *con) } /* Decide whether or not to restart. */ - if (opt.always_rest + if (con->cmd & DO_LIST) + restval = 0; + else if (opt.always_rest && stat (locf, &st) == 0 && S_ISREG (st.st_mode)) /* When -c is used, continue from on-disk size. (Can't use From aed143ea0c070c764fe199b3c35904c6ecf4018a Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Fri, 11 Apr 2008 16:38:43 -0700 Subject: [PATCH 4/4] Fix fuzzy match of ChangeLog. --- src/ChangeLog | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 23a422d7..7201511a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,9 +1,3 @@ -2008-04-10 Alexander Dergachev - - * xmalloc.c, xmalloc.h (memfatal): Now exported; accepts an - "unknown" value for the attempted allocation size. - * utils.c (aprintf): Now calls memfatal, instead of aborting. - 2008-04-11 Micah Cowan * ftp.c (getftp, ftp_loop_internal): Don't append to an existing @@ -11,6 +5,12 @@ Rabin Vincent for pointing the way with a suggested fix! +2008-04-10 Alexander Dergachev + + * xmalloc.c, xmalloc.h (memfatal): Now exported; accepts an + "unknown" value for the attempted allocation size. + * utils.c (aprintf): Now calls memfatal, instead of aborting. + 2008-03-19 Micah Cowan * utils.c (test_dir_matches_p): More tests related for