cvs: /php4 php_variables.c rfc1867.c
| From: | Zeev Suraski | Date: | Tue, 15 Feb 2000 22:51:48 +0000 |
| Subject: | cvs: /php4 php_variables.c rfc1867.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-10318@lists.php.net to get a copy of this message | ||
zeev Tue Feb 15 14:51:48 2000 EDT
Modified files:
/php4 php_variables.c rfc1867.c
Log:
@- Fixed RFC1867 file upload under Windows (Zeev)
Fixed a memory leak
Index: php4/php_variables.c
diff -u php4/php_variables.c:1.4 php4/php_variables.c:1.5
--- php4/php_variables.c:1.4 Sun Feb 13 05:25:01 2000
+++ php4/php_variables.c Tue Feb 15 14:51:18 2000
@@ -192,7 +192,18 @@
INIT_PZVAL(array_ptr);
switch (arg) {
case PARSE_POST:
- zend_hash_add_ptr(&EG(symbol_table), "HTTP_POST_VARS",
sizeof("HTTP_POST_VARS"), array_ptr, sizeof(pval *),NULL);
+ if (zend_hash_add_ptr(&EG(symbol_table), "HTTP_POST_VARS",
sizeof("HTTP_POST_VARS"), array_ptr, sizeof(pval *),NULL)==FAILURE) {
+ zval **p;
+
+ /* This could happen if we're in RFC 1867 file upload */
+ /* The parsing portion of the POST reader should actually move
+ * to this function - Zeev
+ */
+ zval_dtor(array_ptr);
+ FREE_ZVAL(array_ptr);
+ zend_hash_find(&EG(symbol_table), "HTTP_POST_VARS",
sizeof("HTTP_POST_VARS"), (void **) &p);
+ array_ptr = *p;
+ }
break;
case PARSE_GET:
zend_hash_add_ptr(&EG(symbol_table), "HTTP_GET_VARS",
sizeof("HTTP_GET_VARS"), array_ptr, sizeof(pval *),NULL);
Index: php4/rfc1867.c
diff -u php4/rfc1867.c:1.25 php4/rfc1867.c:1.26
--- php4/rfc1867.c:1.25 Sat Feb 12 09:37:11 2000
+++ php4/rfc1867.c Tue Feb 15 14:51:18 2000
@@ -15,7 +15,7 @@
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
-/* $Id: rfc1867.c,v 1.25 2000/02/12 17:37:11 thies Exp $ */
+/* $Id: rfc1867.c,v 1.26 2000/02/15 22:51:18 zeev Exp $ */
#include <stdio.h>
#include "php.h"
@@ -67,8 +67,9 @@
state = 1;
eolsize = 2;
- if(*(loc+len)==0x0a)
+ if(*(loc+len)==0x0a) {
eolsize = 1;
+ }
rem -= (loc - ptr) + len + eolsize;
ptr = loc + len + eolsize;
@@ -204,7 +205,7 @@
php_error(E_WARNING, "File Upload Error - No Mime boundary found after start of file
header");
SAFE_RETURN;
}
- fn = tempnam(PG(upload_tmp_dir), "php");
+ fn = tempnam(PG(upload_tmp_dir), "php");
if ((loc - ptr - 4) > PG(upload_max_filesize)) {
php_error(E_WARNING, "Max file size of %ld bytes exceeded - file [%s] not saved",
PG(upload_max_filesize),namebuf);
bytes=0;
@@ -217,7 +218,7 @@
bytes = 0;
SET_VAR_STRING(namebuf, estrdup("none"));
} else {
- fp = fopen(fn, "w");
+ fp = fopen(fn, "wb");
if (!fp) {
php_error(E_WARNING, "File Upload Error - Unable to open temporary file [%s]", fn);
SAFE_RETURN;