From 42e576ace20355418bdc11226ac045cea4737391 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 10 Apr 2017 19:02:50 +0800 Subject: [PATCH] Fixed bug #74402 (segfault on random_bytes, bin2hex, openssl_seal) --- NEWS | 2 ++ ext/openssl/openssl.c | 1 - ext/openssl/tests/bug74402.phpt | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 ext/openssl/tests/bug74402.phpt diff --git a/NEWS b/NEWS index 5caecbe6cb..613be686ca 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ PHP NEWS loss). (Yussuf Khalil) - OpenSSL: + . Fixed bug #74402 (segfault on random_bytes, bin2hex, openssl_seal). + (Laruence) . Fixed bug #74341 (openssl_x509_parse fails to parse ASN.1 UTCTime without seconds). (Moritz Fain) diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 7a8ccc0a99..1ea4d07e09 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -5399,7 +5399,6 @@ PHP_FUNCTION(openssl_seal) if (len1 + len2 > 0) { zval_dtor(sealdata); - buf[len1 + len2] = '\0'; ZVAL_NEW_STR(sealdata, zend_string_init((char*)buf, len1 + len2, 0)); efree(buf); diff --git a/ext/openssl/tests/bug74402.phpt b/ext/openssl/tests/bug74402.phpt new file mode 100644 index 0000000000..8cd98362df --- /dev/null +++ b/ext/openssl/tests/bug74402.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #74402 (segfault on random_bytes, bin3hex, openssl_seal) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +int(64) +int(80) -- 2.40.0