diff options
author | Scott MacVicar <scottmac@php.net> | 2009-03-29 23:32:17 +0000 |
---|---|---|
committer | Scott MacVicar <scottmac@php.net> | 2009-03-29 23:32:17 +0000 |
commit | bf22f79452117966ae0a80dd07d031b814a5c0bd (patch) | |
tree | 4654b60dd9999e40692e79e79f890f16430441fb /ext/openssl/openssl.c | |
parent | 743efae83abccf48aad6b8d1033d97bd7a5baf5e (diff) | |
download | php-git-bf22f79452117966ae0a80dd07d031b814a5c0bd.tar.gz |
Fix bug #47828 - Converting to UTF-8 can sometimes fail, check error codes and avoid segfault.
Diffstat (limited to 'ext/openssl/openssl.c')
-rw-r--r-- | ext/openssl/openssl.c | 6 |
1 files changed, 4 insertions, 2 deletions
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); } } |