com php-src: Fixed bug #71475: openssl_seal() uninitial ized memory usage: ext/openssl/openssl.c ext/openss l/tests/bug71475.phpt

From: Date: Mon, 01 Feb 2016 04:18:46 +0000
Subject: com php-src: Fixed bug #71475: openssl_seal() uninitial ized memory usage: ext/openssl/openssl.c ext/openss l/tests/bug71475.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-90876@lists.php.net to get a copy of this message
Commit: 33b1fbbb5c0459a623ab91b492f1a37c5262329c Author: Stanislav Malyshev <stas@php.net> Sun, 31 Jan 2016 20:18:46 -0800 Parents: fc53d7408ba12bc0cbed8c20f3258b953c9ea9a5 Branches: PHP-7.0 PHP-7.0.3 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=33b1fbbb5c0459a623ab91b492f1a37c5262329c Log: Fixed bug #71475: openssl_seal() uninitialized memory usage Bugs: https://bugs.php.net/71475 Changed paths: M ext/openssl/openssl.c A ext/openssl/tests/bug71475.phpt Diff: diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index a8ecbb2..75c44a3 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -4938,6 +4938,7 @@ PHP_FUNCTION(openssl_seal) memset(eks, 0, sizeof(*eks) * nkeys); key_resources = safe_emalloc(nkeys, sizeof(zend_resource*), 0); memset(key_resources, 0, sizeof(zend_resource*) * nkeys); + memset(pkeys, 0, sizeof(*pkeys) * nkeys); /* get the public keys we are using to seal this data */ i = 0; @@ -4999,7 +5000,7 @@ PHP_FUNCTION(openssl_seal) clean_exit: for (i=0; i<nkeys; i++) { - if (key_resources[i] == NULL) { + if (key_resources[i] == NULL && pkeys[i] != NULL) { EVP_PKEY_free(pkeys[i]); } if (eks[i]) { diff --git a/ext/openssl/tests/bug71475.phpt b/ext/openssl/tests/bug71475.phpt new file mode 100644 index 0000000..680753d --- /dev/null +++ b/ext/openssl/tests/bug71475.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #71475: openssl_seal() uninitialized memory usage +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip openssl not loaded"); +?> +--FILE-- +<?php +$_ = str_repeat("A", 512); +openssl_seal($_, $_, $_, array_fill(0,64,0)); +?> +DONE +--EXPECTF-- + +Warning: openssl_seal(): not a public key (1th member of pubkeys) in %s/bug71475..php on line %d +DONE \ No newline at end of file

« previous php.cvs (#90876) next »