diff options
author | Christoph M. Becker <cmb@php.net> | 2015-07-03 00:25:03 +0200 |
---|---|---|
committer | Christoph M. Becker <cmb@php.net> | 2015-07-03 00:25:03 +0200 |
commit | caa539b4814f715cb1a53961c85b56c8eb957f39 (patch) | |
tree | 1d467d2348ca564732e7d7e4e498354170acd6a0 /ext | |
parent | 57881e878db7bb2c19833aa44c097ea3af2fbb2e (diff) | |
parent | 616661e0f8368365f50fe9aea7606782aa7552dc (diff) | |
download | php-git-caa539b4814f715cb1a53961c85b56c8eb957f39.tar.gz |
Merge branch 'PHP-5.6'
* PHP-5.6:
updated NEWS
Fix #69975: PHP segfaults when accessing nvarchar(max) defined columns
Diffstat (limited to 'ext')
-rw-r--r-- | ext/odbc/php_odbc.c | 7 | ||||
-rw-r--r-- | ext/odbc/tests/bug69975.phpt | 32 |
2 files changed, 39 insertions, 0 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index b5f3b97845..3451140fc3 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -1014,6 +1014,13 @@ int odbc_bindcols(odbc_result *result) NULL, 0, NULL, &displaysize); } #endif + /* Workaround for drivers that report NVARCHAR(MAX) columns as SQL_WVARCHAR with size 0 (bug #69975) */ + if (result->values[i].coltype == SQL_WVARCHAR && displaysize == 0) { + result->values[i].coltype = SQL_WLONGVARCHAR; + result->values[i].value = NULL; + break; + } + /* Workaround for Oracle ODBC Driver bug (#50162) when fetching TIMESTAMP column */ if (result->values[i].coltype == SQL_TIMESTAMP) { displaysize += 3; diff --git a/ext/odbc/tests/bug69975.phpt b/ext/odbc/tests/bug69975.phpt new file mode 100644 index 0000000000..eca7564519 --- /dev/null +++ b/ext/odbc/tests/bug69975.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #69975 (PHP segfaults when accessing nvarchar(max) defined columns) +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +include 'config.inc'; + +$conn = odbc_connect($dsn, $user, $pass); +@odbc_exec($conn, 'CREATE DATABASE odbcTEST'); +odbc_exec($conn, 'CREATE TABLE FOO (ID INT, VARCHAR_COL NVARCHAR(MAX))'); +odbc_exec($conn, "INSERT INTO FOO VALUES (1, 'foo')"); + +$result = odbc_exec($conn, "SELECT VARCHAR_COL FROM FOO"); +var_dump(odbc_fetch_array($result)); + +echo "ready"; +?> +--EXPECT-- +array(1) { + ["VARCHAR_COL"]=> + string(3) "foo" +} +ready +--CLEAN-- +<?php +include 'config.inc'; + +$conn = odbc_connect($dsn, $user, $pass); +odbc_exec($conn, 'DROP TABLE FOO'); +odbc_exec($conn, 'DROP DATABASE odbcTEST'); +?> |