diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-09-25 13:53:19 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-09-25 13:53:19 +0200 |
commit | 3d148804cc3c99e74ad64e13253660779f838db8 (patch) | |
tree | 565ed0f362b8aacf120aec6e6fd97d188e084612 | |
parent | 439878c8f9d4966eacc504f6d3e35c7cb66c4251 (diff) | |
parent | 1086e4ec886c86653e0f5bb161d067982efbf1ed (diff) | |
download | php-git-3d148804cc3c99e74ad64e13253660779f838db8.tar.gz |
Merge branch 'PHP-7.4' into master
* PHP-7.4:
Fix #80147: BINARY strings may not be properly zero-terminated
-rw-r--r-- | ext/odbc/php_odbc.c | 1 | ||||
-rw-r--r-- | ext/odbc/tests/bug80147.phpt | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 8dc9c75844..bfb72bcff7 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -1870,6 +1870,7 @@ PHP_FUNCTION(odbc_result) if (rc != SQL_SUCCESS_WITH_INFO) { field_str = zend_string_truncate(field_str, result->values[field_ind].vallen, 0); } + ZSTR_VAL(field_str)[ZSTR_LEN(field_str)] = '\0'; RETURN_NEW_STR(field_str); break; diff --git a/ext/odbc/tests/bug80147.phpt b/ext/odbc/tests/bug80147.phpt new file mode 100644 index 0000000000..26e27c534e --- /dev/null +++ b/ext/odbc/tests/bug80147.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #80147 (BINARY strings may not be properly zero-terminated) +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +include 'config.inc'; + +$conn = odbc_connect($dsn, $user, $pass); + +odbc_exec($conn, "CREATE TABLE bug80147 (id INT, whatever VARBINARY(50))"); +odbc_exec($conn, "INSERT INTO bug80147 VALUES (1, CONVERT(VARBINARY(50), 'whatever'))"); + +$res = odbc_exec($conn, "SELECT * FROM bug80147"); +odbc_binmode($res, ODBC_BINMODE_RETURN); +odbc_fetch_row($res); +var_dump(odbc_result($res, 'whatever')); +?> +--CLEAN-- +<?php +include 'config.inc'; + +$conn = odbc_connect($dsn, $user, $pass); +odbc_exec($conn, "DROP TABLE bug80147"); +?> +--EXPECT-- +string(8) "whatever" |