php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62070 Collator::getSortKey returns garbage
Submitted: 2012-05-19 13:24 UTC Modified: 2012-05-23 11:37 UTC
From: clicky at erebot dot net Assigned: cataphract (profile)
Status: Closed Package: I18N and L10N related
PHP Version: 5.4.3 OS: Ubuntu 10.10
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: clicky at erebot dot net
New email:
PHP Version: OS:

 

 [2012-05-19 13:24 UTC] clicky at erebot dot net
Description:
------------
I tried to use the same code snippet as the one given on Collator::getSortKey's manual page (http://php.net/manual/en/collator.getsortkey.php).
This resulted in a PHP Warning about a non zero-terminated string and a different output.

I get the same results (warning + incorrect sort key) on both a 32 bits and a 64 bits build of PHP 5.2.17 (with intl installed from PECL), 5.3.13 & 5.4.3,

Here's the configure line I used for PHP 5.4.3 (64 bits build with debug symbols):

'./configure' \
'--disable-all' \
'--disable-short-tags' \
'--disable-sigchild' \
'--enable-debug' \
'--with-layout=GNU' \
'--with-regex' \
'--with-openssl' \
'--with-zlib' \
'--enable-bcmath' \
'--with-bz2' \
'--enable-calendar' \
'--with-gd' \
'--enable-gd-native-ttf' \
'--with-gettext' \
'--with-gmp' \
'--enable-mbstring' \
'--enable-pcntl' \
'--with-readline' \
'--enable-soap' \
'--enable-sockets' \
'--with-pdo-sqlite' \
'--enable-sysvmsg' \
'--enable-sysvsem' \
'--enable-sysvshm' \
'--with-xsl' \
'--with-iconv' \
'--enable-zip' \
'--enable-posix' \
'--enable-libxml' \
'--enable-dom' \
'--enable-xml' \
'--enable-xmlreader' \
'--enable-xmlwriter' \
'--enable-simplexml' \
'--enable-tokenizer' \
'--enable-pdo' \
'--enable-ctype' \
'--enable-json' \
'--enable-session' \
'--enable-intl' \
'--enable-phar' \
'--with-sqlite3' \
'--prefix=/home/.../php-5.4.3-debug' \
'--exec-prefix=/home/.../php-5.4.3-debug' \
'--with-pear=/home/.../php-5.4.3-debug/pear'


Test script:
---------------
<?php

// Same as the one on http://php.net/manual/en/collator.getsortkey.php

$s1 = 'Hello';

$coll = collator_create( 'en_US' );
$res  = collator_get_sort_key( $coll, $s1);

echo urlencode($res);
?>


Expected result:
----------------
71%3F%3FE%01%09%01%8F%08%00 // No warning and same result as in the manual

Actual result:
--------------
PHP 5.2.17:

PHP Warning:  String is not zero-terminated (:4BBH	) (source: /home/.../php-5.2.17-debug/Zend/zend_execute_API.c:414) in Command line code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
%3A4BBH%01%09%01%8F%08%00

-----

PHP 5.3.13:

PHP Warning:  String is not zero-terminated (:4BBH	) (source: /home/.../php-5.3.13-debug/Zend/zend_execute_API.c:447) in Command line code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
%3A4BBH%01%09%01%8F%08%00

-----

PHP 5.4.3:

PHP Warning:  String is not zero-terminated (:4BBH	) (source: /home/.../php-5.4.3-debug/Zend/zend_execute.h:87) in Command line code on line 1
PHP Stack trace:
PHP   1. {main}() Command line code:0
%3A4BBH%01%09%01%8F%08%00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-19 16:09 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: stas
 [2012-05-23 11:30 UTC] cataphract@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src.git;a=commit;h=51286bd8e5a7acd75326fae497313725e4acf234
Log: Fixed bug #62070
 [2012-05-23 11:37 UTC] cataphract@php.net
-Status: Assigned +Status: Closed -Assigned To: stas +Assigned To: cataphract
 [2012-05-23 11:37 UTC] cataphract@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2014-10-07 23:25 UTC] stas@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=51286bd8e5a7acd75326fae497313725e4acf234
Log: Fixed bug #62070
 [2014-10-07 23:36 UTC] stas@php.net
Automatic comment on behalf of cataphract
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=51286bd8e5a7acd75326fae497313725e4acf234
Log: Fixed bug #62070
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC