]> granicus.if.org Git - php/commitdiff
fix improper behavior
authorAnatol Belski <ab@php.net>
Fri, 3 Jul 2015 08:15:52 +0000 (10:15 +0200)
committerAnatol Belski <ab@php.net>
Fri, 3 Jul 2015 08:15:52 +0000 (10:15 +0200)
openssl_spki_export() is documented to return string, but it's
obviously not achieved writing it to stdout :)

ext/openssl/openssl.c

index ebbc877c43c90236ded059f9afa0e4ee86184721..b3ef5ad00369811400c71dceb8d87caf75963296 100644 (file)
@@ -1637,7 +1637,7 @@ PHP_FUNCTION(openssl_spki_export)
 
        EVP_PKEY *pkey = NULL;
        NETSCAPE_SPKI *spki = NULL;
-       BIO *out = BIO_new(BIO_s_mem());
+       BIO *out = NULL;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &spkstr, &spkstr_len) == FAILURE) {
                return;
@@ -1669,8 +1669,13 @@ PHP_FUNCTION(openssl_spki_export)
                goto cleanup;
        }
 
-       out = BIO_new_fp(stdout, BIO_NOCLOSE);
-       PEM_write_bio_PUBKEY(out, pkey);
+       out = BIO_new(BIO_s_mem());
+       if (out && PEM_write_bio_PUBKEY(out, pkey))  {
+               BUF_MEM *bio_buf;
+
+               BIO_get_mem_ptr(out, &bio_buf);
+               RETVAL_STRINGL((char *)bio_buf->data, bio_buf->length);
+       }
        goto cleanup;
 
 cleanup: