php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48186 Symbol with code 0 in the 255 position of a string
Submitted: 2009-05-08 03:10 UTC Modified: 2015-09-20 04:22 UTC
Votes:8
Avg. Score:4.1 ± 0.9
Reproduced:5 of 5 (100.0%)
Same Version:1 (20.0%)
Same OS:3 (60.0%)
From: aiskrenkov at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: PDO ODBC
PHP Version: 5.2.9 OS: Windows
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-05-08 03:10 UTC] aiskrenkov at gmail dot com
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-08 14:36 UTC] cmb@php.net
-Status: Open +Status: Feedback -Package: ODBC related +Package: PDO ODBC -Assigned To: +Assigned To: cmb
 [2015-09-08 14:36 UTC] cmb@php.net
Is that still an issue with recent PHP versions?
 [2015-09-20 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Oct 18 06:01:27 2019 UTC