]> sjero.net Git - wget/commitdiff
[svn] Committed my patch from <dpd7mj3sap.fsf@mraz.iskon.hr>.
authorhniksic <devnull@localhost>
Fri, 19 May 2000 07:37:22 +0000 (00:37 -0700)
committerhniksic <devnull@localhost>
Fri, 19 May 2000 07:37:22 +0000 (00:37 -0700)
src/ChangeLog
src/ftp.c
src/http.c

index b514899c70e3e59f3a5f20e1e8bc66f261e36722..badeb93f9761bbcc7186628fd47993fe8c44b8fa 100644 (file)
@@ -1,3 +1,9 @@
+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
index 9a7f33d81a13627d4c6135355a64bc09c21a174e..ef611d32df7c936a76577fdaf930100bdcb65d00 100644 (file)
--- 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)
     {
index fde316bfe2c54d43bab0a99f352bd05f34677353..a180d9a13a7f3792997076f7a4a92d81204405c8 100644 (file)
@@ -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)