From: jona at oismail dot com
Operating system: Windows 2000
PHP version: 5.1.4
PHP Bug Type: Reproducible crash
Bug description: pg_escape_string is not capable of escaping null characters
Description:
------------
It appears that pg_escape_string is not capable of escaping null
characters (such as those found in a serialised object with
private/protected member variables).
The returned string is truncated when the null character (\0) is
encountered and thus any data after the null character is lost.
It appears that PostGreSQL has a problem with null characters, as even
using addslashes() for escaping the null character the query executes but
data after the null character is never inserted into the database.
This behaviour is observed on Windows 2000 running PostGreSQL 8.0.3 and
PHP 5.1.4 via IIS 5.0.
Reproduce code:
---------------
<?php
class Test
{
private $privateVar;
protected $protectedVar;
public function __construct($private, $protected)
{
$this->privateVar = $private;
$this->protectedVar = $protected;
}
}
echo pg_escape_string(serialize(new Test("private variable", "protected
variable") ) );
?>
Expected result:
----------------
properly escaped string that can be sent to the PostGreSQL backend
Actual result:
--------------
screen output: O:4:"Test":2:{s:16:"
--
Edit bug report at http://bugs.php.net/?id=37838&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=37838&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=37838&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=37838&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37838&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=37838&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37838&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37838&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37838&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37838&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37838&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=37838&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=37838&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37838&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37838&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37838&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37838&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37838&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37838&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37838&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37838&r=mysqlcfg