]> sjero.net Git - wget/commitdiff
[svn] Fix crash when post-file is missing.
authorhniksic <devnull@localhost>
Sat, 4 Oct 2003 22:26:58 +0000 (15:26 -0700)
committerhniksic <devnull@localhost>
Sat, 4 Oct 2003 22:26:58 +0000 (15:26 -0700)
src/ChangeLog
src/http.c
src/utils.c

index a60938bf9e4b99f34cc3dce4355f5c0ac00bb5b0..ddb203975dc061a58f4a248e142a272fbc913377 100644 (file)
@@ -1,3 +1,8 @@
+2003-10-05  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * utils.c (file_size): Return -1 if fopen() returns NULL.  Prior
+       to this patch, wget --post-file=nosuchfile dumped core.
+
 2003-10-04  Gisle Vanem  <giva@bgnett.no>
 
        * mswindows.c (run_with_timeout): Use WaitForSingleObject to wait
index 6bb53f2d62cda9b780aa4bbf1f224e40890a60ac..92043a57e354e4c4fe92154d8b8c08922a35cd40 100644 (file)
@@ -1015,7 +1015,7 @@ Accept: %s\r\n\
 #endif
            write_error = iwrite (sock, opt.post_data, post_data_size);
        }
-      else if (opt.post_file_name)
+      else if (opt.post_file_name && post_data_size != 0)
        {
 #ifdef HAVE_SSL
          if (conn->scheme == SCHEME_HTTPS)
index fb180e8da5a2754a9e116ab732a41148a8020de0..99b317f7b44236032b5431747d614425406e60d6 100644 (file)
@@ -574,6 +574,8 @@ file_size (const char *filename)
      that way we can also verify whether the file is readable.
      Inspired by the POST patch by Arnaud Wylie.  */
   FILE *fp = fopen (filename, "rb");
+  if (!fp)
+    return -1;
   fseek (fp, 0, SEEK_END);
   size = ftell (fp);
   fclose (fp);