[PHP-CVS] cvs: php-src(PHP_5_3) /main rfc1867.c /tests/basic bug46313-win.phpt bug46313.phpt

2008-10-20 Thread Arnaud Le Blanc
lbarnaudMon Oct 20 17:09:11 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/tests/basicbug46313.phpt bug46313-win.phpt 

  Modified files:  
/php-src/main   rfc1867.c 
  Log:
  Fixed #46313 (Magic quotes broke $_FILES)
  # magic_quotes_gpc was disabled during registration of 
$_FILES[x][tmp_name]
  # and $GLOBALS[x] (which is tmp_name with register_globals enabled). This
  # caused x to not be escaped so there was 2 different keys for the same file
  # in $_FILES, one with tmp_name and the other without.
  # All other variables (name, size, etc) are registered with magic_quotes_gpc
  # untouched, both in $_FILES and $GLOBALS and I did not found a reason for
  # disabling it for tmp_name.
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?r1=1.173.2.1.2.9.2.5r2=1.173.2.1.2.9.2.6diff_format=u
Index: php-src/main/rfc1867.c
diff -u php-src/main/rfc1867.c:1.173.2.1.2.9.2.5 
php-src/main/rfc1867.c:1.173.2.1.2.9.2.6
--- php-src/main/rfc1867.c:1.173.2.1.2.9.2.5Tue Sep 23 15:18:26 2008
+++ php-src/main/rfc1867.c  Mon Oct 20 17:09:10 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.5 2008/09/23 15:18:26 nlopess Exp $ */
+/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.6 2008/10/20 17:09:10 lbarnaud Exp $ */
 
 /*
  *  This product includes software developed by the Apache Group
@@ -1283,8 +1283,6 @@
/* Initialize variables */
add_protected_variable(param TSRMLS_CC);
 
-   magic_quotes_gpc = PG(magic_quotes_gpc);
-   PG(magic_quotes_gpc) = 0;
/* if param is of form xxx[.*] this will cut it to xxx 
*/
if (!is_anonymous) {
safe_php_register_variable(param, 
temp_filename, strlen(temp_filename), NULL, 1 TSRMLS_CC);
@@ -1299,8 +1297,6 @@
add_protected_variable(lbuf TSRMLS_CC);
register_http_post_files_variable(lbuf, temp_filename, 
http_post_files, 1 TSRMLS_CC);
 
-   PG(magic_quotes_gpc) = magic_quotes_gpc;
-
{
zval file_size, error_type;
 

http://cvs.php.net/viewvc.cgi/php-src/tests/basic/bug46313.phpt?view=markuprev=1.1
Index: php-src/tests/basic/bug46313.phpt
+++ php-src/tests/basic/bug46313.phpt

http://cvs.php.net/viewvc.cgi/php-src/tests/basic/bug46313-win.phpt?view=markuprev=1.1
Index: php-src/tests/basic/bug46313-win.phpt
+++ php-src/tests/basic/bug46313-win.phpt



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /main rfc1867.c

2008-10-20 Thread Arnaud Le Blanc
lbarnaudMon Oct 20 18:42:58 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/main   rfc1867.c 
  Log:
  Better fix for #46313
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?r1=1.173.2.1.2.9.2.6r2=1.173.2.1.2.9.2.7diff_format=u
Index: php-src/main/rfc1867.c
diff -u php-src/main/rfc1867.c:1.173.2.1.2.9.2.6 
php-src/main/rfc1867.c:1.173.2.1.2.9.2.7
--- php-src/main/rfc1867.c:1.173.2.1.2.9.2.6Mon Oct 20 17:09:10 2008
+++ php-src/main/rfc1867.c  Mon Oct 20 18:42:58 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.6 2008/10/20 17:09:10 lbarnaud Exp $ */
+/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.7 2008/10/20 18:42:58 lbarnaud Exp $ */
 
 /*
  *  This product includes software developed by the Apache Group
@@ -789,7 +789,6 @@
int str_len = 0, num_vars = 0, num_vars_max = 2*10, *len_list = NULL;
char **val_list = NULL;
 #endif
-   zend_bool magic_quotes_gpc;
multipart_buffer *mbuff;
zval *array_ptr = (zval *) arg;
int fd=-1;
@@ -1280,12 +1279,18 @@
}
s = ;
 
+   {
+   /* store temp_filename as-is (without 
magic_quotes_gpc-ing it, in case upload_tmp_dir
+* contains escapeable characters. escape only the 
variable name.) */
+   zval zfilename;
+
/* Initialize variables */
add_protected_variable(param TSRMLS_CC);
 
/* if param is of form xxx[.*] this will cut it to xxx 
*/
if (!is_anonymous) {
-   safe_php_register_variable(param, 
temp_filename, strlen(temp_filename), NULL, 1 TSRMLS_CC);
+   ZVAL_STRING(zfilename, temp_filename, 1);
+   safe_php_register_variable_ex(param, 
zfilename, NULL, 1 TSRMLS_CC);
}

/* Add $foo[tmp_name] */
@@ -1295,7 +1300,9 @@
snprintf(lbuf, llen, %s[tmp_name], param);
}
add_protected_variable(lbuf TSRMLS_CC);
-   register_http_post_files_variable(lbuf, temp_filename, 
http_post_files, 1 TSRMLS_CC);
+   ZVAL_STRING(zfilename, temp_filename, 1);
+   register_http_post_files_variable_ex(lbuf, zfilename, 
http_post_files, 1 TSRMLS_CC);
+   }
 
{
zval file_size, error_type;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /main rfc1867.c

2008-10-20 Thread Arnaud Le Blanc
lbarnaudMon Oct 20 18:43:32 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/main   rfc1867.c 
  Log:
  WS
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?r1=1.173.2.1.2.9.2.7r2=1.173.2.1.2.9.2.8diff_format=u
Index: php-src/main/rfc1867.c
diff -u php-src/main/rfc1867.c:1.173.2.1.2.9.2.7 
php-src/main/rfc1867.c:1.173.2.1.2.9.2.8
--- php-src/main/rfc1867.c:1.173.2.1.2.9.2.7Mon Oct 20 18:42:58 2008
+++ php-src/main/rfc1867.c  Mon Oct 20 18:43:32 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.7 2008/10/20 18:42:58 lbarnaud Exp $ */
+/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.8 2008/10/20 18:43:32 lbarnaud Exp $ */
 
 /*
  *  This product includes software developed by the Apache Group
@@ -1280,28 +1280,28 @@
s = ;
 
{
-   /* store temp_filename as-is (without 
magic_quotes_gpc-ing it, in case upload_tmp_dir
-* contains escapeable characters. escape only the 
variable name.) */
-   zval zfilename;
+   /* store temp_filename as-is (without 
magic_quotes_gpc-ing it, in case upload_tmp_dir
+* contains escapeable characters. escape only 
the variable name.) */
+   zval zfilename;
 
-   /* Initialize variables */
-   add_protected_variable(param TSRMLS_CC);
+   /* Initialize variables */
+   add_protected_variable(param TSRMLS_CC);
 
-   /* if param is of form xxx[.*] this will cut it to xxx 
*/
-   if (!is_anonymous) {
+   /* if param is of form xxx[.*] this will cut it 
to xxx */
+   if (!is_anonymous) {
+   ZVAL_STRING(zfilename, temp_filename, 
1);
+   safe_php_register_variable_ex(param, 
zfilename, NULL, 1 TSRMLS_CC);
+   }
+   
+   /* Add $foo[tmp_name] */
+   if (is_arr_upload) {
+   snprintf(lbuf, llen, 
%s[tmp_name][%s], abuf, array_index);
+   } else {
+   snprintf(lbuf, llen, %s[tmp_name], 
param);
+   }
+   add_protected_variable(lbuf TSRMLS_CC);
ZVAL_STRING(zfilename, temp_filename, 1);
-   safe_php_register_variable_ex(param, 
zfilename, NULL, 1 TSRMLS_CC);
-   }
-   
-   /* Add $foo[tmp_name] */
-   if (is_arr_upload) {
-   snprintf(lbuf, llen, %s[tmp_name][%s], abuf, 
array_index);
-   } else {
-   snprintf(lbuf, llen, %s[tmp_name], param);
-   }
-   add_protected_variable(lbuf TSRMLS_CC);
-   ZVAL_STRING(zfilename, temp_filename, 1);
-   register_http_post_files_variable_ex(lbuf, zfilename, 
http_post_files, 1 TSRMLS_CC);
+   register_http_post_files_variable_ex(lbuf, 
zfilename, http_post_files, 1 TSRMLS_CC);
}
 
{



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /main rfc1867.c

2008-09-07 Thread Arnaud Le Blanc
lbarnaudSun Sep  7 14:17:47 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/main   rfc1867.c 
  Log:
  MFH: More accurate max_file_size / upload_max_filesize (fixes #45124)
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?r1=1.173.2.1.2.9.2.3r2=1.173.2.1.2.9.2.4diff_format=u
Index: php-src/main/rfc1867.c
diff -u php-src/main/rfc1867.c:1.173.2.1.2.9.2.3 
php-src/main/rfc1867.c:1.173.2.1.2.9.2.4
--- php-src/main/rfc1867.c:1.173.2.1.2.9.2.3Sat Sep  6 17:18:40 2008
+++ php-src/main/rfc1867.c  Sun Sep  7 14:17:47 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.3 2008/09/06 17:18:40 lbarnaud Exp $ */
+/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.4 2008/09/07 14:17:47 lbarnaud Exp $ */
 
 /*
  *  This product includes software developed by the Apache Group
@@ -1077,12 +1077,12 @@
}


-   if (PG(upload_max_filesize)  0  total_bytes 
 PG(upload_max_filesize)) {
+   if (PG(upload_max_filesize)  0  
(total_bytes+blen)  PG(upload_max_filesize)) {
 #if DEBUG_FILE_UPLOAD
sapi_module.sapi_error(E_NOTICE, 
upload_max_filesize of %ld bytes exceeded - file [%s=%s] not saved, 
PG(upload_max_filesize), param, filename);
 #endif
cancel_upload = UPLOAD_ERROR_A;
-   } else if (max_file_size  (total_bytes  
max_file_size)) {
+   } else if (max_file_size  ((total_bytes+blen) 
 max_file_size)) {
 #if DEBUG_FILE_UPLOAD
sapi_module.sapi_error(E_NOTICE, 
MAX_FILE_SIZE of %ld bytes exceeded - file [%s=%s] not saved, max_file_size, 
param, filename);
 #endif



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /main rfc1867.c

2008-09-06 Thread Arnaud Le Blanc
lbarnaudSat Sep  6 17:18:41 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/main   rfc1867.c 
  Log:
  MFH: Fixed #43540 (rfc1867 handler newlength problem)
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?r1=1.173.2.1.2.9.2.2r2=1.173.2.1.2.9.2.3diff_format=u
Index: php-src/main/rfc1867.c
diff -u php-src/main/rfc1867.c:1.173.2.1.2.9.2.2 
php-src/main/rfc1867.c:1.173.2.1.2.9.2.3
--- php-src/main/rfc1867.c:1.173.2.1.2.9.2.2Fri Mar 14 13:11:12 2008
+++ php-src/main/rfc1867.c  Sat Sep  6 17:18:40 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.2 2008/03/14 13:11:12 tony2001 Exp $ */
+/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.3 2008/09/06 17:18:40 lbarnaud Exp $ */
 
 /*
  *  This product includes software developed by the Apache Group
@@ -925,7 +925,7 @@
if (sapi_module.input_filter(PARSE_POST, param, 
value, value_len, new_val_len TSRMLS_CC)) {
if (php_rfc1867_callback != NULL) {
multipart_event_formdata 
event_formdata;
-   size_t newlength = 0;
+   size_t newlength = new_val_len;
 

event_formdata.post_bytes_processed = SG(read_post_bytes);
event_formdata.name = param;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /main rfc1867.c

2008-03-14 Thread Antony Dovgal
tony2001Fri Mar 14 13:11:12 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/main   rfc1867.c 
  Log:
  MFH: check if return value of write() is -1 and abort upload in this case 
setting the correct error status
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?r1=1.173.2.1.2.9.2.1r2=1.173.2.1.2.9.2.2diff_format=u
Index: php-src/main/rfc1867.c
diff -u php-src/main/rfc1867.c:1.173.2.1.2.9.2.1 
php-src/main/rfc1867.c:1.173.2.1.2.9.2.2
--- php-src/main/rfc1867.c:1.173.2.1.2.9.2.1Mon Dec 31 07:17:17 2007
+++ php-src/main/rfc1867.c  Fri Mar 14 13:11:12 2008
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.1 2007/12/31 07:17:17 sebastian Exp $ */
+/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.2 2008/03/14 13:11:12 tony2001 Exp $ */
 
 /*
  *  This product includes software developed by the Apache Group
@@ -1091,7 +1091,13 @@

wlen = write(fd, buff, blen);

-   if (wlen  blen) {
+   if (wlen == -1) {
+   /* write failed */
+#if DEBUG_FILE_UPLOAD
+   
sapi_module.sapi_error(E_NOTICE, write() failed - %s, strerror(errno));
+#endif
+   cancel_upload = UPLOAD_ERROR_F;
+   } else if (wlen  blen) {
 #if DEBUG_FILE_UPLOAD

sapi_module.sapi_error(E_NOTICE, Only %d bytes were written, expected to write 
%d, wlen, blen);
 #endif



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /main rfc1867.c

2008-03-14 Thread Antony Dovgal
Ilia, let me know if you want me to commit this to 5_2.

The patch is supposed to prevent appearing _FILES with negative size and 
missing error when write() fails.

On 03/14/2008 04:11 PM, Antony Dovgal wrote:
 tony2001  Fri Mar 14 13:11:12 2008 UTC
 
   Modified files:  (Branch: PHP_5_3)
 /php-src/main rfc1867.c 
   Log:
   MFH: check if return value of write() is -1 and abort upload in this case 
 setting the correct error status
   
   
 http://cvs.php.net/viewvc.cgi/php-src/main/rfc1867.c?r1=1.173.2.1.2.9.2.1r2=1.173.2.1.2.9.2.2diff_format=u
 Index: php-src/main/rfc1867.c
 diff -u php-src/main/rfc1867.c:1.173.2.1.2.9.2.1 
 php-src/main/rfc1867.c:1.173.2.1.2.9.2.2
 --- php-src/main/rfc1867.c:1.173.2.1.2.9.2.1  Mon Dec 31 07:17:17 2007
 +++ php-src/main/rfc1867.cFri Mar 14 13:11:12 2008
 @@ -17,7 +17,7 @@
 +--+
   */
  
 -/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.1 2007/12/31 07:17:17 sebastian Exp $ */
 +/* $Id: rfc1867.c,v 1.173.2.1.2.9.2.2 2008/03/14 13:11:12 tony2001 Exp $ */
  
  /*
   *  This product includes software developed by the Apache Group
 @@ -1091,7 +1091,13 @@
   
   wlen = write(fd, buff, blen);
   
 - if (wlen  blen) {
 + if (wlen == -1) {
 + /* write failed */
 +#if DEBUG_FILE_UPLOAD
 + 
 sapi_module.sapi_error(E_NOTICE, write() failed - %s, strerror(errno));
 +#endif
 + cancel_upload = UPLOAD_ERROR_F;
 + } else if (wlen  blen) {
  #if DEBUG_FILE_UPLOAD
   
 sapi_module.sapi_error(E_NOTICE, Only %d bytes were written, expected to 
 write %d, wlen, blen);
  #endif
 
 
 


-- 
Wbr, 
Antony Dovgal

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php