php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74381 mcrypt_enc_self_test() returns int not bool; returns 0=good, non-zero=bad
Submitted: 2017-04-06 10:44 UTC Modified: 2019-04-17 15:50 UTC
From: rjhdby@php.net Assigned: girgias (profile)
Status: Closed Package: mcrypt related
PHP Version: Irrelevant OS: -
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rjhdby@php.net
New email:
PHP Version: OS:

 

 [2017-04-06 10:44 UTC] rjhdby@php.net
Description:
------------
---
From manual page: http://www.php.net/function.mcrypt-enc-self-test
---

mcrypt_enc_self_test
The function returns TRUE if the self test succeeds, or FALSE when it fails.

!!!BUT!!!

mcrypt_enc_self_test
If the self test succeeds it returns FALSE. In case of an error, it returns TRUE.




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-06 10:48 UTC] peehaa@php.net
I also like how the signature says int and the return values section says bool.
 [2017-04-06 11:18 UTC] requinix@php.net
-Summary: Possible bug +Summary: mcrypt_enc_self_test() returns int not bool; returns 0=good, non-zero=bad -Type: Bug +Type: Documentation Problem -Package: Documentation problem +Package: mcrypt related
 [2017-04-06 11:18 UTC] requinix@php.net
What's weird is there was a commit to change it to return bool [1] but it got reverted later that day [2].

It definitely returns int [3]. I didn't find the algorithm code on SF (/modules/algorithms is empty?) but from the tarball I see that rc2.c (as a sample) follows the C convention of returning 0 for success and <0 for failure.

We probably shouldn't touch the mcrypt code but fixing the docs should be okay...

[1] https://github.com/php/php-src/commit/472b883cc6834f3791fe037f69ec87c635d44d0c
[2] https://github.com/php/php-src/commit/fbc29e2848fd71f6ab362c644eefccbe48a8a06f
[3] http://mcrypt.cvs.sourceforge.net/viewvc/mcrypt/libmcrypt/lib/mcrypt_modules.c?revision=1.1.1.1&view=markup#l608
 [2019-04-17 15:50 UTC] girgias@php.net
Automatic comment from SVN on behalf of girgias
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=347273
Log: Fix incorrect return values.
Fixes Doc Bug #74381
 [2019-04-17 15:50 UTC] girgias@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: girgias
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 31 16:00:03 2025 UTC