Bug #42765 [Fbk->NoF]: PDO ODBC: Long binary field in query result crashes PHP ("Out of memory" error)

From: Date: Sun, 16 Jul 2017 04:22:31 +0000
Subject: Bug #42765 [Fbk->NoF]: PDO ODBC: Long binary field in query result crashes PHP ("Out of memory" error)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210072@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=42765&edit=1

 ID:               42765
 Updated by:       php-bugs@lists.php.net
 Reported by:      sms at inbox dot ru
 Summary:          PDO ODBC: Long binary field in query result crashes
                   PHP ("Out of memory" error)
-Status:           Feedback
+Status:           No Feedback
 Type:             Bug
 Package:          PDO ODBC
 Operating System: Windows 2000 SP4
 PHP Version:      5.2.4
 Private report:   N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2017-06-29 08:26:37] adambaratz@php.net

I'm trying to reproduce this. Could you confirm some details so I can make sure I'm
changing the right thing? cmb's notes about initializing a value to 0 relate to a different
function.

This report is for a few versions of PHP 5.x, but odbc_stmt_describe looks largely the same between
the PHP-5.6 branch and master. I'm testing with master on Debian 8. I tried both the FreeTDS
and the MS ODBC drivers, connecting to SQL Server 2016. I tried this simple script:

<?php
$pdo = new PDO(...);
$stmt = $pdo->query("select cast(1 as varbinary(max)) as col");
var_dump($stmt->fetchAll());

I didn't get an error with either driver.

------------------------------------------------------------------------
[2016-12-12 17:49:32] amistry at am-productions dot biz

cmb, any update on getting this committed?

------------------------------------------------------------------------
[2016-11-02 18:28:08] cmb@php.net

Thanks for the patch, Anish! Haven't tested it yet, but it looks good
to me.

------------------------------------------------------------------------
[2016-09-21 17:48:07] amistry at am-productions dot biz

As an update to my last post.  That patch is for php 5.6 or later.  If you're trying make this
work with an older version of php (eg. 5.5)  You'll need to also backport the fixes from 5.6 to
odbc_stmt.c with regard to SQL_VARCHAR ,etc. before it will function correctly.

------------------------------------------------------------------------
[2016-09-21 15:16:42] amistry at am-productions dot biz

The following fixes the issue for me.

--- odbc_stmt.c.orig	2016-09-21 10:57:45.052396000 -0400
+++ odbc_stmt.c	2016-09-21 11:05:02.584261000 -0400
@@ -551,8 +551,8 @@
 	struct pdo_column_data *col = &stmt->columns[colno];
 	RETCODE rc;
 	SWORD	colnamelen;
-	SQLULEN	colsize;
-	SQLLEN displaysize;
+	SQLLEN	colsize = 0;
+	SQLLEN displaysize = 0;
 
 	rc = SQLDescribeCol(S->stmt, colno+1, S->cols[colno].colname,
 			sizeof(S->cols[colno].colname)-1, &colnamelen,

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=42765


--
Edit this bug report at https://bugs.php.net/bug.php?id=42765&edit=1


Thread (21 messages)

« previous php.bugs (#210072) next »