1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Fix crash when post-file is missing.

This commit is contained in:
hniksic 2003-10-04 15:26:58 -07:00
parent 711692375e
commit 254291cc03
3 changed files with 8 additions and 1 deletions

View 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

View 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)

View 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);