cvs: php-src(PHP_5_3) /ext/openssl openssl.c /ext/openssl/tests 006.phpt
| From: | Henrique do Nascimento Angelo | Date: | Tue, 15 Jul 2008 02:43:30 +0000 |
| Subject: | cvs: php-src(PHP_5_3) /ext/openssl openssl.c /ext/openssl/tests 006.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-51101@lists.php.net to get a copy of this message | ||
hnangelo Tue Jul 15 02:43:30 2008 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/openssl/tests 006.phpt
Modified files:
/php-src/ext/openssl openssl.c
Log:
Fix segfault caused by openssl_pkey_new() in ext/openssl/tests/006.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/openssl.c?r1=1.98.2.5.2.41.2.12&r2=1.98.2.5.2.41.2.13&diff_format=u
Index: php-src/ext/openssl/openssl.c
diff -u php-src/ext/openssl/openssl.c:1.98.2.5.2.41.2.12
php-src/ext/openssl/openssl.c:1.98.2.5.2.41.2.13
--- php-src/ext/openssl/openssl.c:1.98.2.5.2.41.2.12 Sat Jun 28 09:17:39 2008
+++ php-src/ext/openssl/openssl.c Tue Jul 15 02:43:30 2008
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: openssl.c,v 1.98.2.5.2.41.2.12 2008/06/28 09:17:39 hnangelo Exp $ */
+/* $Id: openssl.c,v 1.98.2.5.2.41.2.13 2008/07/15 02:43:30 hnangelo Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -2912,8 +2912,10 @@
OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, dmp1);
OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, dmq1);
OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, iqmp);
- if (EVP_PKEY_assign_RSA(pkey, rsa)) {
- RETURN_RESOURCE(zend_list_insert(pkey, le_key));
+ if (rsa->n && rsa->d) {
+ if (EVP_PKEY_assign_RSA(pkey, rsa)) {
+ RETURN_RESOURCE(zend_list_insert(pkey, le_key));
+ }
}
RSA_free(rsa);
}
@@ -2931,11 +2933,13 @@
OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, g);
OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, priv_key);
OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, pub_key);
- if (!dsa->priv_key && !dsa->pub_key) {
- DSA_generate_key(dsa);
- }
- if (EVP_PKEY_assign_DSA(pkey, dsa)) {
- RETURN_RESOURCE(zend_list_insert(pkey, le_key));
+ if (dsa->p && dsa->q && dsa->g) {
+ if (!dsa->priv_key && !dsa->pub_key) {
+ DSA_generate_key(dsa);
+ }
+ if (EVP_PKEY_assign_DSA(pkey, dsa)) {
+ RETURN_RESOURCE(zend_list_insert(pkey, le_key));
+ }
}
DSA_free(dsa);
}
@@ -2952,11 +2956,13 @@
OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dh, g);
OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dh, priv_key);
OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dh, pub_key);
- if (!dh->pub_key) {
- DH_generate_key(dh);
- }
- if (EVP_PKEY_assign_DH(pkey, dh)) {
- RETURN_RESOURCE(zend_list_insert(pkey, le_key));
+ if (dh->p && dh->g) {
+ if (!dh->pub_key) {
+ DH_generate_key(dh);
+ }
+ if (EVP_PKEY_assign_DH(pkey, dh)) {
+ RETURN_RESOURCE(zend_list_insert(pkey, le_key));
+ }
}
DH_free(dh);
}
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/tests/006.phpt?view=markup&rev=1.1
Index: php-src/ext/openssl/tests/006.phpt
+++ php-src/ext/openssl/tests/006.phpt