From:             cdf123 at cdf123 dot net
Operating system: Gentoo Linux
PHP version:      5.3.1
PHP Bug Type:     ODBC related
Bug description:  odbc_result for a long varchar with defaultlrl=4k returns 
uninitialized memory

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 bug report at http://bugs.php.net/?id=50597&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=50597&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=50597&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=50597&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=50597&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=50597&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=50597&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=50597&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=50597&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=50597&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=50597&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=50597&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=50597&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=50597&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=50597&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=50597&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=50597&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=50597&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=50597&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=50597&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=50597&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=50597&r=mysqlcfg

Reply via email to