Edit report at http://bugs.php.net/bug.php?id=52924&edit=1
ID: 52924 Updated by: fel...@php.net Reported by: terrafr...@php.net Summary: resource type set to empty after bad mcrypt_generic_init call -Status: Open +Status: Assigned Type: Bug Package: mcrypt related Operating System: Windows 7 PHP Version: 5.3.3 -Assigned To: +Assigned To: derick Block user comment: N New Comment: According to the code, this is required to prevent possible crash. See: result = mcrypt_generic_init(pm->td, key_s, key_size, iv_s); /* If this function fails, close the mcrypt module to prevent crashes * when further functions want to access this resource */ if (result < 0) { zend_list_delete(Z_LVAL_P(mcryptind)); Previous Comments: ------------------------------------------------------------------------ [2010-09-25 21:51:19] terrafr...@php.net Description: ------------ Calling mcrypt_generic_init() with bad values changes the resource type from mcrypt to Unknown. It seems like what should happen is that the resource type should remain the same and that mcrypt_generic_init should simply do nothing. Maybe output a warning (as it currently does) but not change the resource type. A bad call to curl_setopt(), for example, doesn't change the resource type from curl to Unknown as demonstrated thusly: <?php $curl = curl_init(); @curl_setopt($curl); var_dump($curl); ?> Per that it doesn't seem like a bad call to mcrypt_generic_init() ought to change anything either. Test script: --------------- <?php $mcrypt = @mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, ''); @mcrypt_generic_init($mcrypt, '', ''); var_dump($mcrypt); ?> Expected result: ---------------- resource(4) of type (mcrypt) Actual result: -------------- resource(4) of type (Unknown) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52924&edit=1