]> granicus.if.org Git - php/commitdiff
Bug #32491 (File upload error - unable to create a temporary file) - Changing file...
authorUwe Schindler <thetaphi@php.net>
Mon, 4 Apr 2005 15:00:13 +0000 (15:00 +0000)
committerUwe Schindler <thetaphi@php.net>
Mon, 4 Apr 2005 15:00:13 +0000 (15:00 +0000)
NEWS
main/rfc1867.c

diff --git a/NEWS b/NEWS
index 32685ef96ccca7207e64646fdb32b0ac8c91119a..405da5f8b70ebcfc4b437391c6ddbf4d14966994 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ PHP                                                                        NEWS
 - Fixed bug #32560 (configure looks for incorrect db2 library). (Tony)
 - Fixed bug #32530 (chunk_split() does not append endstr if chunklen is  
   longer then the original string). (Ilia)
+- Fixed bug #32491 (File upload error - unable to create a temporary file).
+  (Uwe Schindler)
 - Fixed bug #28839 (SIGSEGV in interactive mode (php -a)).
   (kameshj at fastmail dot fm)
 
index cc54e4e54a233b397e856e74b4ff397849e871e0..adcfc1009944e54f9008cf41bb702d53b21297dd 100644 (file)
@@ -784,7 +784,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
        zend_bool magic_quotes_gpc;
        multipart_buffer *mbuff;
        zval *array_ptr = (zval *) arg;
-       FILE *fp;
+       int fd=-1;
        zend_llist header;
 
        if (SG(request_info).content_length > SG(post_max_size)) {
@@ -969,8 +969,8 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 
                        if (!skip_upload) {
                                /* Handle file */
-                               fp = php_open_temporary_file(PG(upload_tmp_dir), "php", &temp_filename TSRMLS_CC);
-                               if (!fp) {
+                               fd = php_open_temporary_fd(PG(upload_tmp_dir), "php", &temp_filename TSRMLS_CC);
+                               if (fd==-1) {
                                        sapi_module.sapi_error(E_WARNING, "File upload error - unable to create a temporary file");
                                        cancel_upload = UPLOAD_ERROR_E;
                                }
@@ -1001,7 +1001,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
 #endif
                                        cancel_upload = UPLOAD_ERROR_B;
                                } else if (blen > 0) {
-                                       wlen = fwrite(buff, 1, blen, fp);
+                                       wlen = write(fd, buff, blen);
                        
                                        if (wlen < blen) {
 #if DEBUG_FILE_UPLOAD
@@ -1013,8 +1013,8 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
                                        }
                                } 
                        }
-                       if (fp) { /* may not be initialized if file could not be created */
-                               fclose(fp);
+                       if (fd!=-1) { /* may not be initialized if file could not be created */
+                               close(fd);
                        }
 
 #if DEBUG_FILE_UPLOAD