From ee6065f581f6fe17d98166d711f1977f56c67bbf Mon Sep 17 00:00:00 2001 From: hniksic Date: Fri, 19 May 2000 00:37:22 -0700 Subject: [PATCH] [svn] Committed my patch from . --- src/ChangeLog | 6 ++++++ src/ftp.c | 16 ++++++++++++---- src/http.c | 16 ++++++++++++---- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index b514899c..badeb93f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2000-05-18 Hrvoje Niksic + + * ftp.c (getftp): Ditto. + + * http.c (gethttp): Check for return value of fclose/fflush. + 2000-04-12 Hrvoje Niksic * host.c (store_hostaddress): Instead of shifting ADDR, start diff --git a/src/ftp.c b/src/ftp.c index 9a7f33d8..ef611d32 100644 --- a/src/ftp.c +++ b/src/ftp.c @@ -711,10 +711,18 @@ Error in server response, closing control connection.\n")); /* Close data connection socket. */ closeport (dtsock); /* Close the local file. */ - if (!opt.dfp || con->cmd & DO_LIST) - fclose (fp); - else - fflush (fp); + { + /* Close or flush the file. We have to be careful to check for + error here. Checking the result of fwrite() is not enough -- + errors could go unnoticed! */ + int flush_res; + if (!opt.dfp || con->cmd & DO_LIST) + flush_res = fclose (fp); + else + flush_res = fflush (fp); + if (flush_res == EOF) + res = -2; + } /* If get_contents couldn't write to fp, bail out. */ if (res == -2) { diff --git a/src/http.c b/src/http.c index fde316bf..a180d9a1 100644 --- a/src/http.c +++ b/src/http.c @@ -835,10 +835,18 @@ Accept: %s\r\n\ (contlen != -1 ? contlen : 0), &rbuf); hs->dltime = elapsed_time (); - if (!opt.dfp) - fclose (fp); - else - fflush (fp); + { + /* Close or flush the file. We have to be careful to check for + error here. Checking the result of fwrite() is not enough -- + errors could go unnoticed! */ + int flush_res; + if (!opt.dfp) + flush_res = fclose (fp); + else + flush_res = fflush (fp); + if (flush_res == EOF) + hs->res = -2; + } FREE_MAYBE (all_headers); CLOSE (sock); if (hs->res == -2)