Edit report at http://bugs.php.net/bug.php?id=52924&edit=1
ID: 52924 Updated by: [email protected] Reported by: [email protected] Summary: resource type set to empty after bad mcrypt_generic_init call -Status: Assigned +Status: Bogus Type: Bug Package: mcrypt related Operating System: Windows 7 PHP Version: 5.3.3 Assigned To: derick Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2010-09-27 23:54:20] [email protected] 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)); ------------------------------------------------------------------------ [2010-09-25 21:51:19] [email protected] 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
