|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52924 resource type set to empty after bad mcrypt_generic_init call
Submitted: 2010-09-25 21:51 UTC Modified: 2011-05-31 11:59 UTC
From: Assigned: derick (profile)
Status: Not a bug Package: mcrypt related
PHP Version: 5.3.3 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
New email:
PHP Version: OS:


 [2010-09-25 21:51 UTC]
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:

$curl = curl_init();

Per that it doesn't seem like a bad call to mcrypt_generic_init() ought to change anything either.

Test script:
$mcrypt = @mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
@mcrypt_generic_init($mcrypt, '', '');

Expected result:
resource(4) of type (mcrypt)

Actual result:
resource(4) of type (Unknown)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-27 23:54 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2010-09-27 23:54 UTC]
According to the code, this is required to prevent possible crash.

	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) {
 [2011-05-31 11:59 UTC]
-Status: Assigned +Status: Bogus
 [2011-05-31 11:59 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 06:01:30 2024 UTC