cvs: php-src(PHP_5_0) / NEWS /main rfc1867.c
| From: | Ilia Alshanetsky | Date: | Thu, 11 Nov 2004 00:38:45 +0000 |
| Subject: | cvs: php-src(PHP_5_0) / NEWS /main rfc1867.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-29168@lists.php.net to get a copy of this message | ||
iliaa Wed Nov 10 19:38:45 2004 EDT
Modified files: (Branch: PHP_5_0)
/php-src NEWS
/php-src/main rfc1867.c
Log:
MFH: Fixed bug #30750 (Meaningful error message when upload directory is not
accessible).
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1760.2.118&r2=1.1760.2.119&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1760.2.118 php-src/NEWS:1.1760.2.119
--- php-src/NEWS:1.1760.2.118 Tue Nov 9 03:13:01 2004
+++ php-src/NEWS Wed Nov 10 19:38:43 2004
@@ -6,6 +6,8 @@
- Extended the functionality of is_subclass_of() to accept either a class name
or an object as first parameter. (Andrey)
- Fixed potential problems with unserializing invalid serialize data. (Marcus)
+- Fixed bug #30750 (Meaningful error message when upload directory is not
+ accessible). (Ilia)
- Fixed bug #30685 (Malformed SOAPClient http header reequest). (Dmitry)
- Fixed bug #30672 (Problem handling exif data in jpeg images at unusual
places). (Marcus)
http://cvs.php.net/diff.php/php-src/main/rfc1867.c?r1=1.159.2.4&r2=1.159.2.5&ty=u
Index: php-src/main/rfc1867.c
diff -u php-src/main/rfc1867.c:1.159.2.4 php-src/main/rfc1867.c:1.159.2.5
--- php-src/main/rfc1867.c:1.159.2.4 Mon Sep 13 12:00:37 2004
+++ php-src/main/rfc1867.c Wed Nov 10 19:38:44 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: rfc1867.c,v 1.159.2.4 2004/09/13 16:00:37 sesser Exp $ */
+/* $Id: rfc1867.c,v 1.159.2.5 2004/11/11 00:38:44 iliaa Exp $ */
/*
* This product includes software developed by the Apache Group
@@ -130,6 +130,7 @@
#define UPLOAD_ERROR_B 2 /* Uploaded file exceeded MAX_FILE_SIZE */
#define UPLOAD_ERROR_C 3 /* Partially uploaded */
#define UPLOAD_ERROR_D 4 /* No file uploaded */
+#define UPLOAD_ERROR_E 6 /* Missing /tmp or similar directory */
void php_rfc1867_register_constants(TSRMLS_D)
{
@@ -138,6 +139,7 @@
REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_FORM_SIZE", UPLOAD_ERROR_B, CONST_CS |
CONST_PERSISTENT);
REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_PARTIAL", UPLOAD_ERROR_C, CONST_CS |
CONST_PERSISTENT);
REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_NO_FILE", UPLOAD_ERROR_D, CONST_CS |
CONST_PERSISTENT);
+ REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_NO_TMP_DIR", UPLOAD_ERROR_E, CONST_CS |
CONST_PERSISTENT);
}
static void normalize_protected_variable(char *varname TSRMLS_DC)
@@ -963,12 +965,14 @@
}
}
+ total_bytes = cancel_upload = 0;
+
if (!skip_upload) {
/* Handle file */
fp = php_open_temporary_file(PG(upload_tmp_dir), "php", &temp_filename
TSRMLS_CC);
if (!fp) {
sapi_module.sapi_error(E_WARNING, "File upload error - unable to create a temporary
file");
- skip_upload = 1;
+ cancel_upload = UPLOAD_ERROR_E;
}
}
if (skip_upload) {
@@ -977,9 +981,6 @@
continue;
}
- total_bytes = 0;
- cancel_upload = 0;
-
if(strlen(filename) == 0) {
#if DEBUG_FILE_UPLOAD
sapi_module.sapi_error(E_NOTICE, "No file uploaded");
@@ -1011,11 +1012,13 @@
total_bytes += wlen;
}
}
- }
- fclose(fp);
+ }
+ if (fp) { /* may not be initialized if file could not be created */
+ fclose(fp);
+ }
#if DEBUG_FILE_UPLOAD
- if(strlen(filename) > 0 && total_bytes == 0) {
+ if(strlen(filename) > 0 && total_bytes == 0 && !cancel_upload) {
sapi_module.sapi_error(E_WARNING, "Uploaded file size 0 - file [%s=%s] not saved",
param, filename);
cancel_upload = 5;
}
@@ -1023,7 +1026,9 @@
if (cancel_upload) {
if (temp_filename) {
- unlink(temp_filename);
+ if (cancel_upload != UPLOAD_ERROR_E) { /* file creation failed */
+ unlink(temp_filename);
+ }
efree(temp_filename);
}
temp_filename="";