summaryrefslogtreecommitdiff
path: root/lib/formdata.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-01-19 23:08:12 +0100
committerDaniel Stenberg <daniel@haxx.se>2013-01-19 23:08:12 +0100
commitf4cc54cb4746ae5a6d63438aae811f6543b13774 (patch)
treeaca447c0d2d2d1b6034eac331dab62f1a9b61bfc /lib/formdata.c
parent34ae007d4d1a17ec1fbeefc4ef3cf6668e22c3be (diff)
downloadcurl-f4cc54cb4746ae5a6d63438aae811f6543b13774.tar.gz
formadd: reject trying to read a directory where a file is expected
Bug: http://curl.haxx.se/mail/archive-2013-01/0017.html Reported by: Ulrich Doehner
Diffstat (limited to 'lib/formdata.c')
-rw-r--r--lib/formdata.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/formdata.c b/lib/formdata.c
index 6d78b795e..480de98b2 100644
--- a/lib/formdata.c
+++ b/lib/formdata.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -830,9 +830,10 @@ static CURLcode AddFormData(struct FormData **formp,
file */
if(!strequal("-", newform->line)) {
struct_stat file;
- if(!stat(newform->line, &file)) {
+ if(!stat(newform->line, &file) && S_ISREG(file.st_mode))
*size += file.st_size;
- }
+ else
+ return CURLE_BAD_FUNCTION_ARGUMENT;
}
}
}