diff options
author | Uwe Schindler <thetaphi@php.net> | 2005-04-04 14:59:40 +0000 |
---|---|---|
committer | Uwe Schindler <thetaphi@php.net> | 2005-04-04 14:59:40 +0000 |
commit | 4558cdade685dc38681bd09db821d9c5fad8d716 (patch) | |
tree | 30718b581945f6808b4705695d14f3eea573bd7c /main/rfc1867.c | |
parent | f2a3b12445a3948e5ee28d86b8ba70c5fa670e4f (diff) | |
download | php-git-4558cdade685dc38681bd09db821d9c5fad8d716.tar.gz |
Bug #32491 (File upload error - unable to create a temporary file) - Changing file upload from stdio to posix
Diffstat (limited to 'main/rfc1867.c')
-rw-r--r-- | main/rfc1867.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/main/rfc1867.c b/main/rfc1867.c index 54f775ecc8..3987bf8a0c 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -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 |