#26300 [NEW]: PB serialization ascii code greater than 127
| From: | pierre-marie dot mouliere at arc-intl dot com | Date: | Tue, 18 Nov 2003 15:12:41 +0000 |
| Subject: | #26300 [NEW]: PB serialization ascii code greater than 127 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-50634@lists.php.net to get a copy of this message | ||
From: pierre-marie dot mouliere at arc-intl dot com
Operating system: HPUX
PHP version: 4.3.3
PHP Bug Type: WDDX related
Bug description: PB serialization ascii code greater than 127
Description:
------------
Hi,
There's a little bug with strings serialization, for strings containing
characters with ascii code greater than 127 (with HP-UX v11).
We found that the problem is located in function :
php_wddx_serialize_string.
There is a line of code like :
if (iscntrl((int)*p) {
When casting character (*p) to int for values greater than 127 (witch are
considered negative) there is a sign extension so character 'ñ'(ascii code
0xf0) become integer 0xfffffff0.
But the function iscntrl expects an integrer between 0 and 255, or the
result is unpredictable.
The problem can be fixed by modifying the line above like :
if(iscntrl((int)(unsigned char)*p) {
Best Regards
Pierre-Marie MOULIERE
Reproduce code:
---------------
<?php
print "<u>Without locale :</u><br><br>";
print "àâäçéèêëîïôù ÀÂÄÉÈÊËÎÏÔÙ ñ Ñ" . "<br>\n";
print wddx_deserialize(wddx_serialize_value("àâäçéèêëîïôù ÀÂÄÉÈÊËÎÏÔÙ ñ
Ñ"));
print "<br><hr><br>";
print "<u>With locale (fr_FR.iso88591) :</u><br><br>";
setlocale(LC_CTYPE, "fr_FR.iso88591");
print "àâäçéèêëîïôù ÀÂÄÉÈÊËÎÏÔÙ ñ Ñ" . "<br>\n";
print wddx_deserialize(wddx_serialize_value("àâäçéèêëîïôù ÀÂÄÉÈÊËÎÏÔÙ ñ
Ñ"));
?>
Expected result:
----------------
Result :
Without locale :
àâäçéèêëîïôù ÀÂÄÉÈÊËÎÏÔÙ ñ Ñ
àâäçéèêëîïôù ÀÂÄÉÈÊËÎÏÔÙ ñ Ñ
-----------------------------------------------------------
With locale (fr_FR.iso88591) :
àâäçéèêëîïôù ÀÂÄÉÈÊËÎÏÔÙ ñ Ñ
àâäçéèêëîïôù ÀÂÄÉÈÊËÎÏÔÙ ñ Ñ
Actual result:
--------------
Result :
Without locale :
àâäçéèêëîïôù ÀÂÄÉÈÊËÎÏÔÙ ñ Ñ
àâäçéèêëîïôù ÀÂÄÉÈÊËÎÏÔÙ ? Ñ
-----------------------------------------------------------
With locale (fr_FR.iso88591) :
àâäçéèêëîïôù ÀÂÄÉÈÊËÎÏÔÙ ñ Ñ
àâäçéèêëîïôù ÀÂÄ?ÈÊËÎÏÔÙ ñ Ñ
--
Edit bug report at http://bugs.php.net/?id=26300&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26300&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26300&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26300&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26300&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26300&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=26300&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26300&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26300&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26300&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26300&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26300&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26300&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26300&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26300&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26300&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26300&r=float