From: Scott MacVicar Date: Sun, 29 Mar 2009 23:32:17 +0000 (+0000) Subject: Fix bug #47828 - Converting to UTF-8 can sometimes fail, check error codes and avoid... X-Git-Tag: php-5.4.0alpha1~191^2~4024 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bf22f79452117966ae0a80dd07d031b814a5c0bd;p=php Fix bug #47828 - Converting to UTF-8 can sometimes fail, check error codes and avoid segfault. --- diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 90841a7890..01ad14561f 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -557,10 +557,12 @@ static void add_ascii_assoc_name_entry(zval * val, char * key, X509_NAME * name, 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); - add_next_index_utf8_stringl(subentries, (char *)to_add, to_add_len, 1); } else { to_add = ASN1_STRING_data(str); to_add_len = ASN1_STRING_length(str); + } + + if (to_add_len != -1) { add_next_index_utf8_stringl(subentries, (char *)to_add, to_add_len, 1); } } @@ -573,7 +575,7 @@ static void add_ascii_assoc_name_entry(zval * val, char * key, X509_NAME * name, } else { zval_dtor(subentries); FREE_ZVAL(subentries); - if (obj_cnt && str) { + if (obj_cnt && str && to_add_len != -1) { add_ascii_assoc_utf8_stringl(subitem, sname, (char *)to_add, to_add_len, 1); } }