Darshit Shah <[email protected]> writes: > The original patch caused a SIGABRT that I missed. > wget now returns with an exit status of 3. > > Uploading the updated patch file and another with the test to ensure the > correct return code.
Thanks! I have amended some small changes (missing ChangeLog, trailing whitespaces, forgot to add the test to run-px) and this is the version I pushed: >From 50238e49b9e97acc1edf3b4355a2cd44f75660e5 Mon Sep 17 00:00:00 2001 From: Darshit Shah <[email protected]> Date: Tue, 12 Mar 2013 13:11:04 +0530 Subject: [PATCH 1/2] Make wget abort if --post-file does not exist Signed-off-by: Darshit Shah <[email protected]> --- src/ChangeLog | 11 ++++++++++- src/exits.c | 2 +- src/http.c | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c37fb85..8e1213f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,15 @@ +2013-03-12 Darshit Shah <[email protected]> + + * http.c (gethttp): Make wget return FILEBADFILE error and abort if + post-file does not exist. + + * http.c (http_loop): Handle FILEBADFILE as a valid err. + + * exits.c (get_status_for_err): Mark FILEBADFILE as an IO error. + 2013-02-15 Darshit Shah <[email protected]> - * cookies.c (cookie_handle_set_cookie): Set cookie-descard_requested + * cookies.c (cookie_handle_set_cookie): Set cookie->discard_requested to true on domain mismatch. 2012-12-20 Tim Ruehsen <[email protected]> diff --git a/src/exits.c b/src/exits.c index e23fc1c..cea38d5 100644 --- a/src/exits.c +++ b/src/exits.c @@ -58,7 +58,7 @@ get_status_for_err (uerr_t err) case RETROK: return WGET_EXIT_SUCCESS; case FOPENERR: case FOPEN_EXCL_ERR: case FWRITEERR: case WRITEFAILED: - case UNLINKERR: case CLOSEFAILED: + case UNLINKERR: case CLOSEFAILED: case FILEBADFILE: return WGET_EXIT_IO_FAIL; case NOCONERROR: case HOSTERR: case CONSOCKERR: case CONERROR: case CONSSLERR: case CONIMPOSSIBLE: case FTPRERR: case FTPINVPASV: diff --git a/src/http.c b/src/http.c index fdb0d7e..b393e24 100644 --- a/src/http.c +++ b/src/http.c @@ -1865,7 +1865,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy, { logprintf (LOG_NOTQUIET, _("POST data file %s missing: %s\n"), quote (opt.post_file_name), strerror (errno)); - post_data_size = 0; + return FILEBADFILE; } } request_set_header (req, "Content-Length", @@ -3119,6 +3119,7 @@ Spider mode enabled. Check if remote file exists.\n")); quote (hstat.local_file), strerror (errno)); case HOSTERR: case CONIMPOSSIBLE: case PROXERR: case AUTHFAILED: case SSLINITFAILED: case CONTNOTSUPPORTED: case VERIFCERTERR: + case FILEBADFILE: /* Fatal errors just return from the function. */ ret = err; goto exit; -- 1.7.10.4 >From e3b3ea51205b5d9852783dfde526a05100144682 Mon Sep 17 00:00:00 2001 From: Darshit Shah <[email protected]> Date: Tue, 12 Mar 2013 12:21:07 +0530 Subject: [PATCH 2/2] Add test to ensure correct return code on --post-file failure Signed-off-by: Darshit Shah <[email protected]> --- tests/ChangeLog | 6 ++++++ tests/Makefile.am | 1 + tests/Test--post-file.px | 23 +++++++++++++++++++++++ tests/run-px | 1 + 4 files changed, 31 insertions(+) create mode 100755 tests/Test--post-file.px diff --git a/tests/ChangeLog b/tests/ChangeLog index 3650f82..8cd4864 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2013-03-12 Darshit Shah <[email protected]> + + * Makefile.am (EXTRA_DIST): Add Test--post-file.px. + * run-px (tests): Likewise. + * Test--post-file.px: New file. + 2012-11-09 Tim Ruehsen <[email protected]> * HTTPServer.pm: added check for must-not-match request-header diff --git a/tests/Makefile.am b/tests/Makefile.am index 9ff302c..ac6a663 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -119,6 +119,7 @@ EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \ Test-O--no-content-disposition-trivial.px \ Test-O-nonexisting.px \ Test-O.px \ + Test--post-file.px \ Test-proxied-https-auth.px \ Test-proxy-auth-basic.px \ Test-restrict-ascii.px \ diff --git a/tests/Test--post-file.px b/tests/Test--post-file.px new file mode 100755 index 0000000..1c017b7 --- /dev/null +++ b/tests/Test--post-file.px @@ -0,0 +1,23 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use HTTPTest; + + +############################################################################### + +my $cmdline = $WgetTest::WGETPATH . " -d --post-file=nofile http://localhost:{{port}}/"; + +my $expected_error_code = 3; + + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test-missing-file", + cmdline => $cmdline, + errcode => $expected_error_code); +exit $the_test->run(); + +# vim: et ts=4 sw=4 diff --git a/tests/run-px b/tests/run-px index 657194f..3c35d6f 100755 --- a/tests/run-px +++ b/tests/run-px @@ -70,6 +70,7 @@ my @tests = ( 'Test-O--no-content-disposition-trivial.px', 'Test-O-nonexisting.px', 'Test-O.px', + 'Test--post-file.px', 'Test-O-nc.px', 'Test-restrict-ascii.px', 'Test-Restrict-Lowercase.px', -- 1.7.10.4 -- Giuseppe
