From: aiskrenkov at gmail dot com
Operating system: Windows
PHP version: 5.2.9
PHP Bug Type: ODBC related
Bug description: Symbol with code 0 in the 255 position of a string
Description:
------------
Environment:
Windows Server 2003 EE
MS SQL server 8.0.818 (MSDE 2000)
PHP 5.2.6(or high) as ISAPI or cli
I have a table 'session':
[id] [char](32) NOT NULL DEFAULT (''),
[expiry] [bigint] NOT NULL DEFAULT ('0'),
[data] [ntext] NOT NULL DEFAULT ('')
When I retrive data from table and size of data more then 255 bytes, I
found symbol with code 0(as EOL for strings) in the 255 position of the
string.
Reproduce code:
---------------
<?php
$dbname = "session_db";
$username = "sa";
$pw = "1q2w3e";
$pdo = new PDO ("odbc:session_db","sa","1q2w3e");
$query = $pdo->query("delete from session");
$string = '--';
$string .=
'123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890';
$string .= '--';
echo 'Length of source string: '.strlen($string)."\n";
$query = $pdo->query("insert into session values('".md5(time())."',
".time().", '".$string."')");
var_dump($query);
$rowset = $pdo->query("select * from session");
if($rowset === false) {
var_dump($pdo->errorInfo());
}
var_dump($rowset);
$string = $rowset->fetchAll();
//$string = $rowset->fetchColumn(2);
var_dump($string);
echo 'Length of target string: '.strlen($string[0][2])."\n";
?>
Expected result:
----------------
123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
Actual result:
--------------
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123_45678901234567890123456789012345678901234567890
--
Edit bug report at http://bugs.php.net/?id=48186&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48186&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48186&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48186&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48186&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48186&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48186&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48186&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48186&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48186&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48186&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48186&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48186&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48186&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48186&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48186&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48186&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48186&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48186&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48186&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48186&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48186&r=mysqlcfg