php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | |
Patch openssl_x509_parse_bug_fix for OpenSSL related Bug #64802Patch version 2013-08-09 16:25 UTC Return to Bug #64802 | Download this patchThis patch renders other patches obsolete Obsolete patches: Patch Revisions:Developer: mark@zedwood.com--- ext/openssl/openssl.c 2013-07-18 07:37:33.000000000 -0700 +++ ext/openssl/openssl.c 2013-08-08 17:57:45.639903291 -0700 @@ -571,6 +571,7 @@ static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int shortname TSRMLS_DC) /* {{{ */ { + zval **data; zval *subitem, *subentries; int i, j = -1, last = -1, obj_cnt = 0; char *sname; @@ -602,39 +603,34 @@ sname = (char *) OBJ_nid2ln(nid); } - MAKE_STD_ZVAL(subentries); - array_init(subentries); - - last = -1; - for (;;) { - j = X509_NAME_get_index_by_OBJ(name, obj, last); - if (j < 0) { - if (last != -1) break; - } else { - obj_cnt++; - ne = X509_NAME_get_entry(name, j); - str = X509_NAME_ENTRY_get_data(ne); - if (ASN1_STRING_type(str) != V_ASN1_UTF8STRING) { - to_add_len = ASN1_STRING_to_UTF8(&to_add, str); - if (to_add_len != -1) { - add_next_index_stringl(subentries, (char *)to_add, to_add_len, 1); - } - } else { - to_add = ASN1_STRING_data(str); - to_add_len = ASN1_STRING_length(str); + str = X509_NAME_ENTRY_get_data(ne); + if (ASN1_STRING_type(str) != V_ASN1_UTF8STRING) { + to_add_len = ASN1_STRING_to_UTF8(&to_add, str); + } else { + to_add = ASN1_STRING_data(str); + to_add_len = ASN1_STRING_length(str); + } + + if (to_add_len != -1) + { + if (zend_hash_find(Z_ARRVAL_P(subitem), sname, strlen(sname)+1, (void**)&data) == SUCCESS) + { + if (Z_TYPE_PP(data) == IS_ARRAY) + { + subentries = *data; add_next_index_stringl(subentries, (char *)to_add, to_add_len, 1); } + else if (Z_TYPE_PP(data) == IS_STRING) + { + MAKE_STD_ZVAL(subentries); + array_init(subentries); + add_next_index_stringl(subentries, Z_STRVAL_PP(data), Z_STRLEN_PP(data), 1); + add_next_index_stringl(subentries, (char *)to_add, to_add_len, 1); + zend_hash_update(Z_ARRVAL_P(subitem), sname, strlen(sname)+1, &subentries, sizeof(zval*), NULL); + } } - last = j; - } - i = last; - - if (obj_cnt > 1) { - add_assoc_zval_ex(subitem, sname, strlen(sname) + 1, subentries); - } else { - zval_dtor(subentries); - FREE_ZVAL(subentries); - if (obj_cnt && str && to_add_len > -1) { + else + { add_assoc_stringl(subitem, sname, (char *)to_add, to_add_len, 1); } } |
Copyright © 2001-2024 The PHP Group All rights reserved. |
Last updated: Sat Dec 14 17:01:25 2024 UTC |