tony2001                Mon Mar 26 10:25:42 2007 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/standard/tests/strings bug40915.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/standard       string.c 
  Log:
  MFH: fix #40915 (addcslashes unexpected behavior with binary input)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.612&r2=1.2027.2.547.2.613&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.612 php-src/NEWS:1.2027.2.547.2.613
--- php-src/NEWS:1.2027.2.547.2.612     Fri Mar 23 20:22:52 2007
+++ php-src/NEWS        Mon Mar 26 10:25:41 2007
@@ -35,6 +35,7 @@
 - Fixed zend_llist_remove_tail (Michael Wallner, Dmitry)
 - Fixed a thread safety issue in gd gif read code (Nuno, Roman Nemecek)
 - Fixed CVE-2007-1001, GD wbmp used with invalid image size (Pierre)
+- Fixed bug #40915 (addcslashes unexpected behavior with binary input). (Tony)
 - Fixed bug #40899 (memory leak when nesting list()). (Dmitry)
 - Fixed bug #40883 (mysql_query() is allocating memory incorrectly). (Tony)
 - Fixed bug #40872 (inconsistency in offsetSet, offsetExists treatment of 
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/string.c?r1=1.445.2.14.2.53&r2=1.445.2.14.2.54&diff_format=u
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.445.2.14.2.53 
php-src/ext/standard/string.c:1.445.2.14.2.54
--- php-src/ext/standard/string.c:1.445.2.14.2.53       Mon Mar 12 23:42:26 2007
+++ php-src/ext/standard/string.c       Mon Mar 26 10:25:41 2007
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: string.c,v 1.445.2.14.2.53 2007/03/12 23:42:26 tony2001 Exp $ */
+/* $Id: string.c,v 1.445.2.14.2.54 2007/03/26 10:25:41 tony2001 Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
@@ -2858,11 +2858,8 @@
                RETURN_STRINGL(Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1);
        }
 
-       RETURN_STRING(php_addcslashes(Z_STRVAL_PP(str), 
-                                     Z_STRLEN_PP(str), 
-                                     &Z_STRLEN_P(return_value), 0, 
-                                     Z_STRVAL_PP(what),
-                                     Z_STRLEN_PP(what) TSRMLS_CC), 0);
+       Z_STRVAL_P(return_value) = php_addcslashes(Z_STRVAL_PP(str), 
Z_STRLEN_PP(str), &Z_STRLEN_P(return_value), 0, Z_STRVAL_PP(what), 
Z_STRLEN_PP(what) TSRMLS_CC);
+       RETURN_STRINGL(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), 0);
 }
 /* }}} */
 

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug40915.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/bug40915.phpt
+++ php-src/ext/standard/tests/strings/bug40915.phpt
--TEST--
Bug #40915 (addcslashes unexpected behavior with binary input)
--FILE--
<?php

$str = (binary)"a\000z";

var_dump(addslashes($str));
var_dump(addcslashes($str, (binary)""));
var_dump(addcslashes($str, (binary)"\000z"));
var_dump(addcslashes( $str, (binary)"z"));

echo "Done\n";
?>
--EXPECTF--     
string(4) "a\0z"
string(3) "a
string(7) "a\000\z"
string(4) "a
Done
--UEXPECTF--
unicode(4) "a\0z"
string(3) "a
string(7) "a\000\z"
string(4) "a
Done

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

Reply via email to