Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- openssl_pkey_new() error tests --EXTENSIONS-- openssl --FILE-- <?php /* openssl_p..

Decoded Output download

--TEST--
openssl_pkey_new() error tests
--EXTENSIONS--
openssl
--FILE--
<?php
/* openssl_pkey_get_details() segfaults when getting the information
    from openssl_pkey_new() with an empty sub-array arg 		*/

$rsa = array("rsa" => array());
$dsa = array("dsa" => array());
$dh = array("dh" => array());

try {
    openssl_pkey_get_details(openssl_pkey_new($rsa));
} catch (TypeError $e) {
    echo $e->getMessage(), "
";
}
try {
    openssl_pkey_get_details(openssl_pkey_new($dsa));
} catch (TypeError $e) {
    echo $e->getMessage(), "
";
}
try {
    openssl_pkey_get_details(openssl_pkey_new($dh));
} catch (TypeError $e) {
    echo $e->getMessage(), "
";
}
?>
--EXPECT--
openssl_pkey_get_details(): Argument #1 ($key) must be of type OpenSSLAsymmetricKey, bool given
openssl_pkey_get_details(): Argument #1 ($key) must be of type OpenSSLAsymmetricKey, bool given
openssl_pkey_get_details(): Argument #1 ($key) must be of type OpenSSLAsymmetricKey, bool given

Did this file decode correctly?

Original Code

--TEST--
openssl_pkey_new() error tests
--EXTENSIONS--
openssl
--FILE--
<?php
/* openssl_pkey_get_details() segfaults when getting the information
    from openssl_pkey_new() with an empty sub-array arg 		*/

$rsa = array("rsa" => array());
$dsa = array("dsa" => array());
$dh = array("dh" => array());

try {
    openssl_pkey_get_details(openssl_pkey_new($rsa));
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}
try {
    openssl_pkey_get_details(openssl_pkey_new($dsa));
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}
try {
    openssl_pkey_get_details(openssl_pkey_new($dh));
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}
?>
--EXPECT--
openssl_pkey_get_details(): Argument #1 ($key) must be of type OpenSSLAsymmetricKey, bool given
openssl_pkey_get_details(): Argument #1 ($key) must be of type OpenSSLAsymmetricKey, bool given
openssl_pkey_get_details(): Argument #1 ($key) must be of type OpenSSLAsymmetricKey, bool given

Function Calls

None

Variables

$dh [{'key': 'dh', 'value': []}]
$dsa [{'key': 'dsa', 'value': []}]
$rsa [{'key': 'rsa', 'value': []}]

Stats

MD5 a99881e905e9f3f315617d0f7aebc314
Eval Count 0
Decode Time 80 ms