php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57702 Multiple BLOB fetch fails
Submitted: 2007-06-14 19:24 UTC Modified: 2016-03-08 01:26 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: discobean+pecl at gmail dot com Assigned: sixd (profile)
Status: Closed Package: PDO OCI
PHP Version: 5.2.1 OS: Linux 2.6.20-15
Private report: No CVE-ID: None
 [2007-06-14 19:24 UTC] discobean+pecl at gmail dot com
Description:
------------
I am using the Oracle OCI Driver that comes with PHP 5.2.1, compiled against the Oracle Instant Client for x86 Version 10.2.0.3.

This WORKS (it var dumps 1 row)
$query = 'select myblob from mytable where id in (445, 446)';
$stmt = $db->prepare($query);
$stmt->execute();

$row = $stmt->fetch();
var_dump($row);

This is BROKEN (it does not var_dump anything)
$query = 'select myclob from mytable where id in (445, 446)';
$stmt = $db->prepare($query);
$stmt->execute();

$row = $stmt->fetch();
var_dump($row);

// I'm now fetching the second CLOB column, and it won't
// var_dump anything
$row = $stmt->fetch();
var_dump($row);


Reproduce code:
---------------
$query = 'select myclob from mytable where id in (445, 446)';
$stmt = $db->prepare($query);
$stmt->execute();

$row = $stmt->fetch();
var_dump($row);

// I'm now fetching the second CLOB column, and it won't
// var_dump anything
$row = $stmt->fetch();
var_dump($row);

Expected result:
----------------
It should var_dump two rows.

Actual result:
--------------
It does not var_dump anything

Patches

57702-PHP-5.4-20120623.patch (last revision 2012-06-23 09:28 UTC by hswong3i at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-23 16:44 UTC] s dot guilford at dbplugins dot com
I have fixed this bug.  Move the line of code in oci_statement:oci_blob_close which free's the LOB locator to oci_stmt_dtor.  Here is the correced code:

static int oci_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
...
..
	if (S->cols) {
		for (i = 0; i < stmt->column_count; i++) {
			if (S->cols[i].data) {
				switch (S->cols[i].dtype) {
					case SQLT_BLOB:
					case SQLT_CLOB:
						OCIDescriptorFree(S->cols[i].data, OCI_DTYPE_LOB);
						break;
					default:
						efree(S->cols[i].data);
				}
			}
		}
		efree(S->cols);
		S->cols = NULL;
	}
...
...
} /* }}} */

static int oci_blob_close(php_stream *stream, int close_handle TSRMLS_DC)
{
	struct oci_lob_self *self = (struct oci_lob_self*)stream->abstract;
	pdo_stmt_t *stmt = self->stmt;

	if (close_handle) {
		OCILobClose(self->S->H->svc, self->S->err, self->lob);
		efree(self);
	}

	php_pdo_stmt_delref(stmt TSRMLS_CC);
	return 0;
}
 [2012-06-23 09:33 UTC] hswong3i at gmail dot com
When developing Drupal 7.x pdo_oci driver (https://github.com/hswong3i/oci) I face this bug too.

Once review with latest patch + cleanup + combo patch with https://bugs.php.net/patch-display.php?bug_id=52958&patch=52958-PHP-5.4-20120623.patch&revision=latest, the segfault no longer exists on 5.4.5-dev (20120623) + Ubuntu 12.04.

may someone apply this patch and get it fixed?
 [2012-06-24 13:06 UTC] hswong3i at gmail dot com
Sorry for using legacy patch contribute style... Renew as pull request at Github:
* https://github.com/php/php-src/pull/118
 [2012-07-01 00:08 UTC] stas@php.net
-Package: PDO_OCI +Package: *General Issues -Assigned To: +Assigned To: sixd
 [2012-10-26 05:55 UTC] sixd@php.net
-Package: *General Issues +Package: PDO related -Assigned To: sixd +Assigned To:
 [2013-01-15 07:32 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2013-01-15 07:32 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4fcf4e084508ae18dddc02891f7c6fb10e49447e
Log: Fixed bug #57702 (Multi-row BLOB fetches)
 [2013-01-15 07:33 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4fcf4e084508ae18dddc02891f7c6fb10e49447e
Log: Fixed bug #57702 (Multi-row BLOB fetches)
 [2013-01-15 07:34 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4fcf4e084508ae18dddc02891f7c6fb10e49447e
Log: Fixed bug #57702 (Multi-row BLOB fetches)
 [2013-03-18 18:02 UTC] kissifrot at gmail dot com
Will this be fixed in 5.3.x too?
 [2014-10-07 23:20 UTC] stas@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=4fcf4e084508ae18dddc02891f7c6fb10e49447e
Log: Fixed bug #57702 (Multi-row BLOB fetches)
 [2014-10-07 23:31 UTC] stas@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=4fcf4e084508ae18dddc02891f7c6fb10e49447e
Log: Fixed bug #57702 (Multi-row BLOB fetches)
 [2016-03-08 01:26 UTC] sixd@php.net
-Package: PDO related +Package: PDO OCI -Assigned To: +Assigned To: sixd
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC