php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | |
Patch openssl_parse_patch for OpenSSL related Bug #64802Patch version 2013-08-06 23:16 UTC Return to Bug #64802 | Download this patchThis patch is obsolete Obsoleted by patches: Patch Revisions:Developer: mark@zedwood.com--- php-5.5.1/ext/openssl/openssl.c 2013-07-18 07:37:33.000000000 -0700 +++ php-5.5.1_mod/ext/openssl/openssl.c 2013-08-06 16:13:31.630562337 -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,35 @@ 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); + add_next_index_stringl(subentries, (char *)to_add, to_add_len, 1); + } + + 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: Sun Oct 06 19:01:27 2024 UTC |