Bug #50597 [Opn->Dup]: odbc_result for a long varchar with defaultlrl=4k returns uninitialized memory
| From: | cmb@php.net | Date: | Tue, 06 Oct 2020 15:58:56 +0000 |
| Subject: | Bug #50597 [Opn->Dup]: odbc_result for a long varchar with defaultlrl=4k returns uninitialized memory | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-229429@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=50597&edit=1
ID: 50597
Updated by: cmb@php.net
Reported by: cdf123 at cdf123 dot net
Summary: odbc_result for a long varchar with defaultlrl=4k
returns uninitialized memory
-Status: Open
+Status: Duplicate
Type: Bug
Package: ODBC related
Operating System: Gentoo Linux
PHP Version: 5.3.1
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
I'm closing this as duplicate of bug #80147, which has recently
been fixed.
Previous Comments:
------------------------------------------------------------------------
[2009-12-28 20:59:25] cdf123 at cdf123 dot net
Description:
------------
odbc_result looks like it is initializing the result string to the length of the data in the field,
but the defaultlrl is limits how much is returned, so the remaining bytes seem to be random
uninitialized memory.
Reproduce code:
---------------
<?php
$data = '000';
for($x=1;$x<12;$x++) $data .= $data;
$db = odbc_connect('DSN', 'user', 'pass');
odbc_exec($db, 'CREATE TABLE Temp (id int, seq int, contents varchar(8000))');
odbc_exec($db, 'INSERT INTO Temp (id, seq, contents) VALUES (1, 1, \'' . $data .
'\')');
$rst = odbc_exec($db, 'select * from Temp');
while(odbc_fetch_row($rst)) echo odbc_result($rst, 'contents');
odbc_free_result($rst);
?>
Expected result:
----------------
4096 '0's
Actual result:
--------------
4096 '0's and 2048 bytes of binary data
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=50597&edit=1