+2000-05-18 Hrvoje Niksic <hniksic@iskon.hr>
+
+ * ftp.c (getftp): Ditto.
+
+ * http.c (gethttp): Check for return value of fclose/fflush.
+
2000-04-12 Hrvoje Niksic <hniksic@iskon.hr>
* host.c (store_hostaddress): Instead of shifting ADDR, start
/* 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)
{
(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)