+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
#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)
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);