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)