php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44618 Fetching may rely on uninitialized data
Submitted: 2008-04-02 16:15 UTC Modified: 2020-10-06 11:38 UTC
Votes:5
Avg. Score:4.2 ± 1.6
Reproduced:3 of 4 (75.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: charlie at strausesoftware dot com Assigned: cmb (profile)
Status: Verified Package: ODBC related
PHP Version: 7.3 OS: Windows 2000
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-04-02 16:15 UTC] charlie at strausesoftware dot com
Description:
------------
I'm using PHP with Apache. PHP code connects to MS SQL server using ODBC.

I'm doing a query against a table that is very simple: one column of the 
real data type, one of the text data type.

The text field is set to "testing 1,2,3". The real column is set to 
10.0199995.

When I use the default connect options, I get both values back fine.

When I use  SQL_CUR_USE_ODBC, which I very much want to use, then the text 
column data comes back as boolean(false).


Reproduce code:
---------------
Table:

CREATE TABLE [dbo].[test1](
[ID] [int] IDENTITY(1,1) NOT NULL,

[real1] [real] NULL,

[text1] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

CONSTRAINT [PK_test1] PRIMARY KEY CLUSTERED

(

[ID] ASC

)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

Insert 1 row where text1 is set to "testing 1,2,3" and real1 is set to 10.0199995.

Code:

<?php
$conn = odbc_connect(db-name, user-name,password, SQL_CUR_USE_ODBC);
$result = odbc_exec($conn, "select * from test1");
if (odbc_fetch_row($result)) {
 print "Values: " . odbc_result($result,"real1") . "," . 
odbc_result($result,"text1");
}
?>


Expected result:
----------------
Values: 10.02,testing 1,2,3 

Actual result:
--------------
Values: 10.02, 

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-02 19:51 UTC] charlie at strausesoftware dot com
Actually, it fails just on a single text column in the table. If its text. Changing it to ntext in this case, works.
 [2008-04-16 15:26 UTC] charlie at strausesoftware dot com
On second thought, having that exact real number value in the real number field needs to be there for the error to happen.
 [2020-10-05 14:36 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2020-10-05 14:36 UTC] cmb@php.net
I confirm this issue with ODBC 17 Driver for SQL Server.  The ODBC
cursor library has a hard time to emulate SQLGetData()[1] which is
used by the ODBC extension to retrieve "long" data.  Given that
the ODBC cursor library is deprecated, I don't see a point in
trying to improve the current handling, except that we really need
to properly handle the SQL_NO_DATA result.

[1] <https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/sqlgetdata-cursor-library>
 [2020-10-06 11:38 UTC] cmb@php.net
-Summary: Problem when using SQL_CUR_USE_ODBC on connec +Summary: Fetching may rely on uninitialized data -PHP Version: 5.2.5 +PHP Version: 7.3
 [2020-10-06 11:38 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #44618: Fetching may rely on uninitialized data
On GitHub:  https://github.com/php/php-src/pull/6281
Patch:      https://github.com/php/php-src/pull/6281.patch
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Oct 25 06:01:24 2020 UTC