diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2019-10-19 11:41:28 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2019-10-19 11:47:00 +0200 |
commit | 45a7723267741be4867306d18b15a4a27d67b0f7 (patch) | |
tree | 20bbd74769cc5ed12a32baadd61d45d3f3bf2c52 | |
parent | d2cde0bfd39422be3af49f6513a0a5358ef7cf63 (diff) | |
download | php-git-45a7723267741be4867306d18b15a4a27d67b0f7.tar.gz |
Fix #78694: Appending to a variant array causes segfault
`write_dimension` object handlers have to be able to handle `NULL`
`offset`s; for now we simply throw an exception instead of following
the `NULL` pointer.
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | ext/com_dotnet/com_handlers.c | 5 | ||||
-rw-r--r-- | ext/com_dotnet/tests/bug78694.phpt | 19 |
3 files changed, 27 insertions, 0 deletions
@@ -6,6 +6,9 @@ PHP NEWS . Fixed bug #78656 (Parse errors classified as highest log-level). (Erik Lundin) +- COM: + . Fixed bug #78694 (Appending to a variant array causes segfault). (cmb) + - Date: . Fixed bug #70153 (\DateInterval incorrectly unserialized). (Maksim Iakunin) diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index 1fc6c04c9a..e7b0aa4bf4 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -127,6 +127,11 @@ static void com_write_dimension(zval *object, zval *offset, zval *value) obj = CDNO_FETCH(object); + if (offset == NULL) { + php_com_throw_exception(DISP_E_BADINDEX, "appending to variants is not supported"); + return; + } + if (V_VT(&obj->v) == VT_DISPATCH) { ZVAL_COPY_VALUE(&args[0], offset); ZVAL_COPY_VALUE(&args[1], value); diff --git a/ext/com_dotnet/tests/bug78694.phpt b/ext/com_dotnet/tests/bug78694.phpt new file mode 100644 index 0000000000..adf0c828ca --- /dev/null +++ b/ext/com_dotnet/tests/bug78694.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #78694 (Appending to a variant array causes segfault) +--SKIPIF-- +<?php +if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available'); +?> +--FILE-- +<?php +foreach ([new com('WScript.Shell'), new variant([])] as $var) { + try { + $var[] = 42; + } catch (com_exception $ex) { + var_dump($ex->getMessage()); + } +} +?> +--EXPECT-- +string(38) "appending to variants is not supported" +string(38) "appending to variants is not supported" |