summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfoobar <sniper@php.net>2001-11-24 18:23:35 +0000
committerfoobar <sniper@php.net>2001-11-24 18:23:35 +0000
commit6083eb1030182419aea0dd943bdd93cdf7c1fa71 (patch)
tree5220254f2f6d1a3e87ed9657cabdae5b6c44b010
parentee111cf9c8d4ba1d0c1b7b91f2691f82b005702f (diff)
downloadphp-git-6083eb1030182419aea0dd943bdd93cdf7c1fa71.tar.gz
- Handle more error types when uploading files.
-rw-r--r--main/rfc1867.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/main/rfc1867.c b/main/rfc1867.c
index cf7de8cb47..b2a2a7a895 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -51,10 +51,11 @@
#define MAX_SIZE_OF_INDEX sizeof("[tmp_name]")
/* Errors */
-#define UPLOAD_ERROR_A 2 /* Uploaded file exceeded upload_max_filesize */
-#define UPLOAD_ERROR_B 3 /* Uploaded file exceeded MAX_FILE_SIZE */
-#define UPLOAD_ERROR_C 4 /* Only partiallly uploaded */
-
+#define UPLOAD_ERROR_A 1 /* Uploaded file exceeded upload_max_filesize */
+#define UPLOAD_ERROR_B 2 /* Uploaded file exceeded MAX_FILE_SIZE */
+#define UPLOAD_ERROR_C 3 /* Only partiallly uploaded */
+#define UPLOAD_ERROR_D 4 /* No file uploaded */
+#define UPLOAD_ERROR_E 5 /* Uploaded file size 0 bytes */
static void add_protected_variable(char *varname TSRMLS_DC)
{
@@ -695,6 +696,11 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
total_bytes = 0;
cancel_upload = 0;
+ if(strlen(filename) == 0) {
+ sapi_module.sapi_error(E_WARNING, "No file uploaded");
+ cancel_upload = UPLOAD_ERROR_D;
+ }
+
while (!cancel_upload && (blen = multipart_buffer_read(mbuff, buff, sizeof(buff) TSRMLS_CC)))
{
if (total_bytes > PG(upload_max_filesize)) {
@@ -715,6 +721,11 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
}
}
fclose(fp);
+
+ if(strlen(filename) > 0 && total_bytes == 0) {
+ sapi_module.sapi_error(E_WARNING, "Uploaded file size 0 - file [%s=%s] not saved", param, filename);
+ cancel_upload = UPLOAD_ERROR_E;
+ }
if (cancel_upload || total_bytes == 0) {