com php-src: Do not add already added object to the internal OpenSSL table: ext/openssl/openssl.c

[email protected] (Jakub Zelenka)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    c0203c0cebcb22b892a6923ca7afc086c96c391c
Author:    Jakub Zelenka <[email protected]>         Wed, 3 Aug 2016 20:01:41 +0100
Parents:   f639b64dca0a72bd7cbb8f773d8934036a175e20
Branches:  PHP-7.0

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=c0203c0cebcb22b892a6923ca7afc086c96c391c

Log:
Do not add already added object to the internal OpenSSL table

This fixes OpenSSL 1.1 where adding object with OID that has been
already added causes an error - preventing of duplication.

Changed paths:
  M  ext/openssl/openssl.c


Diff:
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index f490677..1242a80 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -1007,7 +1007,8 @@ static int add_oid_section(struct php_x509_request * req) /* {{{ */
 	}
 	for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) {
 		cnf = sk_CONF_VALUE_value(sktmp, i);
-		if (OBJ_create(cnf->value, cnf->name, cnf->name) == NID_undef) {
+		if (OBJ_sn2nid(cnf->name) == NID_undef && OBJ_ln2nid(cnf->name) == NID_undef &&
+				OBJ_create(cnf->value, cnf->name, cnf->name) == NID_undef) {
 			php_error_docref(NULL, E_WARNING, "problem creating object %s=%s", cnf->name, cnf->value);
 			return FAILURE;
 		}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.