mirror of
https://github.com/php/php-src.git
synced 2024-09-29 22:06:09 +00:00
16db4d1462
The SQL Server Native Client 11.0 and maybe other ODBC drivers report NVARCHAR(MAX) columns as SQL_WVARCHAR with size 0. This causes too small a buffer to be emalloc'd, likely causing a segfault in the following. As we don't know the real size of the column data, we treat such colums as SQL_WLONGVARCHAR. The related bug #67437 suggests that some drivers report a size of ~4GB. It is not certain that this is really the case (there might be some integer overflow involved, and anyway, there has been no feedback), so we do not cater for this now. However, it would not be hard to treat all sizes above a certain threshold in a similar way, i.e. as SQL_WLONGVARCHAR.
33 lines
726 B
PHP
33 lines
726 B
PHP
--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');
|
|
?>
|