php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15503 Mcrypt segfaults if not correctly calling mcrypt_module_close()
Submitted: 2002-02-11 08:36 UTC Modified: 2002-02-11 10:05 UTC
From: jukkaho at mail dot student dot oulu dot fi Assigned:
Status: Closed Package: mcrypt related
PHP Version: 4.1.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jukkaho at mail dot student dot oulu dot fi
New email:
PHP Version: OS:

 

 [2002-02-11 08:36 UTC] jukkaho at mail dot student dot oulu dot fi
Following script demonstrates the problem:
<?php
 $key="test";
 $td = mcrypt_module_open(MCRYPT_BLOWFISH, "", MCRYPT_MODE_ECB, "");
 $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);

 mcrypt_generic_init ($td, $key, $iv);
 $encrypted_text=mcrypt_generic($td,$input);
 mcrypt_generic_end($td);
 mcrypt_module_close($td); // <- *** Remove this line for segfault ***

 $td = mcrypt_module_open (MCRYPT_BLOWFISH, "", MCRYPT_MODE_ECB, "");
 $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
 mcrypt_generic_init ($td, $key, $iv);
 $decrypted_text=mdecrypt_generic($td,$encrypted_text);
 mcrypt_generic_end($td);
 mcrypt_module_close($td);
 echo date("s")."<br>\n";
 echo "encrypted_text: ".htmlspecialchars($encrypted_text)."<br>\n";
 echo "decrypted_text: ".htmlspecialchars($decrypted_text)."<br>\n";
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-11 08:38 UTC] derick@php.net
What is the version of libmcrypt you are using?
Please use mcrypt_generic_deinit instead of mcrypt_generic_end.
Make a backtrace please.

Derick
 [2002-02-11 08:38 UTC] jukkaho at mail dot student dot oulu dot fi
Forgot to tell:
apache 1.3.20
libmcrypt 2.4.22
 [2002-02-11 08:45 UTC] jukkaho at mail dot student dot oulu dot fi
Fatal error: Call to undefined function: mcrypt_generic_deinit() in ...

PHP Version 4.1.1 confirms phpinfo();

How should I make a backtrace? There's no core.
 [2002-02-11 08:49 UTC] derick@php.net
Ah, it's already fixed in CVS. Can you try a snapshot from snaps.php.net ?

Derick
 [2002-02-11 09:07 UTC] jukkaho at mail dot student dot oulu dot fi
I try and report back soon.
 [2002-02-11 09:44 UTC] jukkaho at mail dot student dot oulu dot fi
Ok, cvs version does not die with signals any more regardless what function calls I leave, but for some reason $decrypted_text seems to be empty (as in \0 characters) all the time. Something wrong in my code that should cause this?

Source output from my code through less:
08<br>
encrypted_text: 4U<83><9F>~5}<8C><br>
decrypted_text: ^@^@^@^@^@^@^@^@<br>
 [2002-02-11 09:47 UTC] jukkaho at mail dot student dot oulu dot fi
Hmm.. previous one was with key "testing testing".. this is with key "test" as in example:
42<br>
encrypted_text: ?<9A>?p??/^S<br>
decrypted_text: ^@^@^@^@^@^@^@^@<br>

So.. always 8 null characters.
 [2002-02-11 10:03 UTC] jukkaho at mail dot student dot oulu dot fi
Should I open a new bug for this or is this some other issue?
 [2002-02-11 10:05 UTC] jukkaho at mail dot student dot oulu dot fi
Damn it. There's no $input in my script!
 [2002-02-11 10:05 UTC] derick@php.net
Hello,

defining $input to the text that you want to encrypt should be enough :)

Derick
 [2002-02-11 10:06 UTC] jukkaho at mail dot student dot oulu dot fi
Yep. That was it.. sorry :) Closed as it should be.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 10 11:01:32 2024 UTC