]> granicus.if.org Git - php/commitdiff
- MFB: fix leaks in openssl context options
authorPierre Joye <pajoye@php.net>
Fri, 26 May 2006 01:48:25 +0000 (01:48 +0000)
committerPierre Joye <pajoye@php.net>
Fri, 26 May 2006 01:48:25 +0000 (01:48 +0000)
ext/openssl/xp_ssl.c

index 4a5e302a41a0da44ae7ac6b4715b750e8d9a09d5..b83db488f1a40b540f6a3563a607b337fcc31aa5 100644 (file)
@@ -432,6 +432,7 @@ static inline int php_openssl_enable_crypto(php_stream *stream,
                                                                "ssl", "peer_certificate",
                                                                zcert);
                                                peer_cert = NULL;
+                                               efree(zcert);
                                        }
 
                                        if (SUCCESS == php_stream_context_get_option(
@@ -445,7 +446,7 @@ static inline int php_openssl_enable_crypto(php_stream *stream,
                                                chain = SSL_get_peer_cert_chain(
                                                                        sslsock->ssl_handle);
 
-                                               if (chain) {
+                                               if (chain && sk_X509_num(chain) > 0) {
                                                        int i;
                                                        array_init(arr);
 
@@ -458,6 +459,7 @@ static inline int php_openssl_enable_crypto(php_stream *stream,
                                                                                        php_openssl_get_x509_list_id()));
                                                                add_next_index_zval(arr, zcert);
                                                        }
+                                                       efree(zcert);
                                                } else {
                                                        ZVAL_NULL(arr);
                                                }
@@ -465,6 +467,8 @@ static inline int php_openssl_enable_crypto(php_stream *stream,
                                                php_stream_context_set_option(stream->context,
                                                                "ssl", "peer_certificate_chain",
                                                                arr);
+                                               zval_dtor(arr);
+                                               efree(arr);
                                        }
                                }
                        }