#26300 [Opn->Csd]: PB serialization ascii code greater than 127

From: Date: Tue, 18 Nov 2003 20:24:54 +0000
Subject: #26300 [Opn->Csd]: PB serialization ascii code greater than 127
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-50656@lists.php.net to get a copy of this message
 ID:               26300
 Updated by:       iliaa@php.net
 Reported By:      pierre-marie dot mouliere at arc-intl dot com
-Status:           Open
+Status:           Closed
 Bug Type:         WDDX related
 Operating System: HPUX
 PHP Version:      4.3.3
 New Comment:

Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php




Previous Comments:
------------------------------------------------------------------------

[2003-11-18 10:12:41] pierre-marie dot mouliere at arc-intl dot com

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 this bug report at http://bugs.php.net/?id=26300&edit=1


Thread (2 messages)

« previous php.bugs (#50656) next »