Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDOStatement::getColumnMeta() crash/segfault #224

Closed
v-kigos opened this issue Jan 12, 2017 · 5 comments
Closed

PDOStatement::getColumnMeta() crash/segfault #224

v-kigos opened this issue Jan 12, 2017 · 5 comments

Comments

@v-kigos
Copy link
Contributor

v-kigos commented Jan 12, 2017

PHP call for $stmt->getColumnMeta($index) will crash in Windows, and produce
segmentation fault in Linux if index is out of the range (exceeds the number of columns).

Repro script:

<?php
/* Connect to an SQL server */
$conn = new PDO("sqlsrv:server=$server", $user, $password);  

/* Retrieve metadata for a column */
$stmt = $conn->query("select name from sys.databases");  
$metadata = $stmt->getColumnMeta(2);
var_dump($metadata);  
?>
@yitam
Copy link
Contributor

yitam commented Jan 20, 2017

It also crashes when prepare() is used instead of query() even when the column index is valid.

$stmt = $conn->prepare("select name from sys.databases");
$metadata = $stmt->getColumnMeta(0);
var_dump($metadata);

@v-kigos
Copy link
Contributor Author

v-kigos commented Jan 27, 2017

MSDN does not define return values for this case,
see https://msdn.microsoft.com/en-us/library/ff628182(v=sql.105).aspx

PHP help suggests: Returns FALSE if the requested column does not exist in the result set, or if no result set exists, see http://php.net/manual/en/pdostatement.getcolumnmeta.php

@yitam
Copy link
Contributor

yitam commented Jan 30, 2017

Fixed by #261

@yitam yitam closed this as completed Jan 30, 2017
@eaglebush
Copy link

My development system is Windows 7 SP1 and the PDO_SQLSRV I use is 4.1.4. The only problem I am having is PDOStatement::getColumnMeta() crash/segfault #224, fixed in 4.3.0. However, this version does not support Windows 7 SP1. Can't we have an update on PDO_SQLSRV 4.1.4 of this bug?

@yitam
Copy link
Contributor

yitam commented Feb 22, 2018

Yes @eaglebush , starting with v4.3.0 we stopped supporting Windows 7. That means we will no longer test our drivers in Windows 7 platforms, but it doesn't mean the drivers will break. Please feel free to try out v4.3.0 in your Windows 7 SP1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants