[PHP-CVS] svn: /php/php-src/trunk/ext/standard/ string.c tests/strings/bug60801.phpt
aharvey Mon, 30 Jan 2012 13:29:15 + Revision: http://svn.php.net/viewvc?view=revisionrevision=322934 Log: Fix bug #60801 (strpbrk() mishandles NUL byte) on trunk only for now. Bug: https://bugs.php.net/60801 (Assigned) strpbrk() mishandles NUL byte Changed paths: U php/php-src/trunk/ext/standard/string.c A php/php-src/trunk/ext/standard/tests/strings/bug60801.phpt Modified: php/php-src/trunk/ext/standard/string.c === --- php/php-src/trunk/ext/standard/string.c 2012-01-30 13:02:10 UTC (rev 322933) +++ php/php-src/trunk/ext/standard/string.c 2012-01-30 13:29:15 UTC (rev 322934) @@ -5315,7 +5315,7 @@ { char *haystack, *char_list; int haystack_len, char_list_len; - char *p; + char *haystack_ptr, *cl_ptr; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss, haystack, haystack_len, char_list, char_list_len) == FAILURE) { RETURN_FALSE; @@ -5326,11 +5326,15 @@ RETURN_FALSE; } - if ((p = strpbrk(haystack, char_list))) { - RETURN_STRINGL(p, (haystack + haystack_len - p), 1); - } else { - RETURN_FALSE; + for (haystack_ptr = haystack; haystack_ptr (haystack + haystack_len); ++haystack_ptr) { + for (cl_ptr = char_list; cl_ptr (char_list + char_list_len); ++cl_ptr) { + if (*cl_ptr == *haystack_ptr) { + RETURN_STRINGL(haystack_ptr, (haystack + haystack_len - haystack_ptr), 1); + } + } } + + RETURN_FALSE; } /* }}} */ Added: php/php-src/trunk/ext/standard/tests/strings/bug60801.phpt === --- php/php-src/trunk/ext/standard/tests/strings/bug60801.phpt (rev 0) +++ php/php-src/trunk/ext/standard/tests/strings/bug60801.phpt 2012-01-30 13:29:15 UTC (rev 322934) @@ -0,0 +1,23 @@ +--TEST-- +Bug #60801 (strpbrk() mishandles NUL byte) +--FILE-- +?php +$haystack = foob\x00ar; +$needle = a\x00b; + +var_dump(strpbrk($haystack, 'ar')); +var_dump(strpbrk($haystack, \x00)); +var_dump(strpbrk($haystack, $needle)); +var_dump(strpbrk('foobar', $needle)); +var_dump(strpbrk(\x00, $needle)); +var_dump(strpbrk('xyz', $needle)); +var_dump(strpbrk($haystack, 'xyz')); +? +--EXPECT-- +string(2) ar +string(3) +string(4) b +string(3) bar +string(1) +bool(false) +bool(false) Property changes on: php/php-src/trunk/ext/standard/tests/strings/bug60801.phpt ___ Added: svn:mime-type + text/x-php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/standard/ string.c
pierrick Fri, 20 Jan 2012 13:20:14 + Revision: http://svn.php.net/viewvc?view=revisionrevision=322497 Log: Remove memory leak in substr_replace (to commit in 5.4 after code freeze) Changed paths: U php/php-src/trunk/ext/standard/string.c Modified: php/php-src/trunk/ext/standard/string.c === --- php/php-src/trunk/ext/standard/string.c 2012-01-20 12:31:37 UTC (rev 322496) +++ php/php-src/trunk/ext/standard/string.c 2012-01-20 13:20:14 UTC (rev 322497) @@ -2518,6 +2518,9 @@ if(Z_REFCOUNT_P(orig_str) != refcount) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Argument was modified while replacing); + if(Z_TYPE_PP(tmp_repl) != IS_STRING) { + zval_dtor(repl_str); + } break; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/standard/ string.c
aharvey Tue, 20 Jul 2010 04:26:57 + Revision: http://svn.php.net/viewvc?view=revisionrevision=301412 Log: Fix bug #52380 (Typo in lcfirst comment docs) by updating the commented prototype for lcfirst() to actually read lcfirst(). Bug: http://bugs.php.net/52380 (Assigned) Typo in lcfirst comment docs Changed paths: U php/php-src/trunk/ext/standard/string.c Modified: php/php-src/trunk/ext/standard/string.c === --- php/php-src/trunk/ext/standard/string.c 2010-07-20 04:25:14 UTC (rev 301411) +++ php/php-src/trunk/ext/standard/string.c 2010-07-20 04:26:57 UTC (rev 301412) @@ -2571,7 +2571,7 @@ } /* }}} */ -/* {{{ proto string ucfirst(string str) +/* {{{ proto string lcfirst(string str) Make a string's first character lowercase */ PHP_FUNCTION(lcfirst) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/standard/ string.c
dmitry Wed, 16 Dec 2009 11:15:22 + Revision: http://svn.php.net/viewvc?view=revisionrevision=292195 Log: Fixed str_replace() to work with both binary and unicode strings Changed paths: U php/php-src/trunk/ext/standard/string.c Modified: php/php-src/trunk/ext/standard/string.c === --- php/php-src/trunk/ext/standard/string.c 2009-12-16 10:49:54 UTC (rev 292194) +++ php/php-src/trunk/ext/standard/string.c 2009-12-16 11:15:22 UTC (rev 292195) @@ -5402,17 +5402,25 @@ static void php_str_replace_in_subject(zval *search, zval *replace, zval **subject, zval *result, int case_sensitivity, int *replace_count TSRMLS_DC) { zval**search_entry, - **replace_entry = NULL, + **replace_entry, +*replace_value, + temp_replace, temp_result; - zstr replace_value = NULL_ZSTR; - int replace_len = 0; /* Make sure we're dealing with strings. */ - convert_to_unicode_ex(subject); - Z_TYPE_P(result) = IS_UNICODE; - if (Z_UNILEN_PP(subject) == 0) { - ZVAL_EMPTY_UNICODE(result); - return; + if (Z_TYPE_PP(subject) == IS_STRING) { + Z_TYPE_P(result) = IS_STRING; + if (Z_UNILEN_PP(subject) == 0) { + ZVAL_EMPTY_STRING(result); + return; + } + } else { + convert_to_unicode_ex(subject); + Z_TYPE_P(result) = IS_UNICODE; + if (Z_UNILEN_PP(subject) == 0) { + ZVAL_EMPTY_UNICODE(result); + return; + } } /* If search is an array */ @@ -5426,15 +5434,13 @@ zend_hash_internal_pointer_reset(Z_ARRVAL_P(replace)); } else { /* Set replacement value to the passed one */ - replace_value = Z_UNIVAL_P(replace); - replace_len = Z_UNILEN_P(replace); + replace_value = replace; } /* For each entry in the search array, get the entry */ while (zend_hash_get_current_data(Z_ARRVAL_P(search), (void **) search_entry) == SUCCESS) { /* Make sure we're dealing with strings. */ SEPARATE_ZVAL(search_entry); - convert_to_unicode(*search_entry); if (Z_UNILEN_PP(search_entry) == 0) { zend_hash_move_forward(Z_ARRVAL_P(search)); if (Z_TYPE_P(replace) == IS_ARRAY) { @@ -5447,47 +5453,23 @@ if (Z_TYPE_P(replace) == IS_ARRAY) { /* Get current entry */ if (zend_hash_get_current_data(Z_ARRVAL_P(replace), (void **)replace_entry) == SUCCESS) { - /* Make sure we're dealing with strings. */ SEPARATE_ZVAL(replace_entry); - convert_to_unicode(*replace_entry); - - /* Set replacement value to the one we got from array */ - replace_value = Z_UNIVAL_PP(replace_entry); - replace_len = Z_UNILEN_PP(replace_entry); - + replace_value = *replace_entry; zend_hash_move_forward(Z_ARRVAL_P(replace)); } else { /* We've run out of replacement strings, so use an empty one. */ - replace_value = EMPTY_ZSTR; - replace_len = 0; + replace_value = temp_replace; + Z_UNILEN_P(replace_value) = 0; + Z_UNIVAL_P(replace_value) = EMPTY_ZSTR; + if (Z_TYPE_PP(subject) == IS_STRING) { + Z_TYPE_P(replace_value) = IS_STRING; + } else { + Z_TYPE_P(replace_value) = IS_UNICODE; + } } } - if (Z_UNILEN_PP(search_entry) == 1) { - if (case_sensitivity) { - php_u_char_to_str_ex(Z_USTRVAL_P(result), Z_USTRLEN_P(result), -
[PHP-CVS] svn: /php/php-src/trunk/ext/standard/ string.c
kalleTue, 24 Nov 2009 11:08:16 + Revision: http://svn.php.net/viewvc?view=revisionrevision=291259 Log: Fixed #50226 (Insufficient memory allocation for unicode string) - Patch by yoarvi at gmail dot com Bug: http://bugs.php.net/50226 (Open) [PATCH] - Insufficient memory allocation for unicode string Changed paths: U php/php-src/trunk/ext/standard/string.c Modified: php/php-src/trunk/ext/standard/string.c === --- php/php-src/trunk/ext/standard/string.c 2009-11-24 11:02:47 UTC (rev 291258) +++ php/php-src/trunk/ext/standard/string.c 2009-11-24 11:08:16 UTC (rev 291259) @@ -3457,7 +3457,7 @@ if (type == IS_UNICODE) { old_end.u = old.u + old_len; - str.u = safe_emalloc(2, UBYTES(old_len), 1); + str.u = safe_emalloc(2, UBYTES(old_len), UBYTES(1)); for (p.u = old.u, q.u = str.u; p.u != old_end.u; p.u++) { cp = *p.u; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] svn: /php/php-src/trunk/ext/standard/ string.c tests/strings/str_replace.phpt tests/strings/stripos.phpt tests/strings/stripos_variation1.phpt tests/strings/stripos_variation10.phpt t
On Sat, Aug 15, 2009 at 07:43, Stanislav Malyshevs...@php.net wrote: stas Sat, 15 Aug 2009 05:43:18 + Revision: http://svn.php.net/viewvc?view=revisionrevision=287313 Log: cleanup string parameter parsing, fix some tests Changed paths: U php/php-src/trunk/ext/standard/string.c +static long php_needle_char(zval *needle) { [...] + default: { + php_error_docref(NULL TSRMLS_CC, E_WARNING, needle is not a string or an integer); you are missing TSRMLS_DC -Hannes -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php