From:             [EMAIL PROTECTED]
Operating system: Linux
PHP version:      5CVS-2007-05-10 (CVS)
PHP Bug Type:     OpenSSL related
Bug description:  openssl_pkcs12_read() does not verify the type of the first 
arg

Description:
------------
Function openssl_pkcs12_read() does not check the type of the first
argument and uses it as a string in the call to BIO_write().
So if you pass a number as the first parameter, BIO_write() is called with
a garbage params and segfaults.

Reproduce code:
---------------
$a = 2;
openssl_pkcs12_read(1, $a, 1);

Actual result:
--------------
(gdb) r -r '$a = 2; openssl_pkcs12_read(1, $a, 1);'
Starting program: /home/tony/php-src_5_2/sapi/cli/php -r '$a = 1;
openssl_pkcs12_read(1, $a, 1);'
[Thread debugging using libthread_db enabled]
[New Thread 182900459904 (LWP 1209)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 182900459904 (LWP 1209)]
0x00000031aef70bc0 in memcpy () from /lib64/tls/libc.so.6
(gdb) bt
#0  0x00000031aef70bc0 in memcpy () from /lib64/tls/libc.so.6
#1  0x0000000000ac9f4b in mem_write ()
#2  0x0000000000ac9136 in BIO_write ()
#3  0x0000000000499009 in zif_openssl_pkcs12_read (ht=3,
return_value=0x2a95b92fe8, return_value_ptr=0x0, this_ptr=0x0,
return_value_used=0, tsrm_ls=0x1080450)
    at /home/tony/php-src_5_2/ext/openssl/openssl.c:1565
#4  0x0000000000a1693e in zend_do_fcall_common_helper_SPEC
(execute_data=0x7fbffff1b0, tsrm_ls=0x1080450) at zend_vm_execute.h:200
#5  0x0000000000a1c49a in ZEND_DO_FCALL_SPEC_CONST_HANDLER
(execute_data=0x7fbffff1b0, tsrm_ls=0x1080450) at zend_vm_execute.h:1681
#6  0x0000000000a16246 in execute (op_array=0x2a95b928a0,
tsrm_ls=0x1080450) at zend_vm_execute.h:92
#7  0x00000000009cc67e in zend_eval_string (str=0x7fbffffbf9 "$a = 1;
openssl_pkcs12_read(1, $a, 1);", retval_ptr=0x0, string_name=0xdfa8fc
"Command line code",
    tsrm_ls=0x1080450) at
/home/tony/php-src_5_2/Zend/zend_execute_API.c:1148
#8  0x00000000009cc8ca in zend_eval_string_ex (str=0x7fbffffbf9 "$a = 1;
openssl_pkcs12_read(1, $a, 1);", retval_ptr=0x0, string_name=0xdfa8fc
"Command line code",
    handle_exceptions=1, tsrm_ls=0x1080450) at
/home/tony/php-src_5_2/Zend/zend_execute_API.c:1182
#9  0x0000000000a92527 in main (argc=3, argv=0x7fbffff9e8) at
/home/tony/php-src_5_2/sapi/cli/php_cli.c:1177


-- 
Edit bug report at http://bugs.php.net/?id=41353&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41353&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41353&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41353&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41353&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41353&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41353&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41353&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41353&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41353&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41353&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41353&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41353&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41353&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41353&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41353&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41353&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41353&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41353&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41353&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41353&r=mysqlcfg

Reply via email to