Bug #81546 [NEW]: md2 parameter 2 expects bool but treats truthy as true

From: Date: Wed, 20 Oct 2021 10:22:21 +0000
Subject: Bug #81546 [NEW]: md2 parameter 2 expects bool but treats truthy as true
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237295@lists.php.net to get a copy of this message
From: devstemail at gmail dot com Operating system: Centos 8 PHP version: 8.1.0RC4 Package: hash related Bug Type: Bug Bug description:md2 parameter 2 expects bool but treats truthy as true Description: ------------ $binary treats truthy values (e.g. non-empty string) as true ``` $binary = 'hello'; echo md5( 'abc', $binary ); ``` outputs a binary md5, instead of a hex md5, even though we didn't pass true It should only output a binary md5 if $binary === true, not if $binary == true As the documentation states: >If the optional binary is set to **true**, then the md5 digest is instead returned in raw binary format with a length of 16. # Solution Basically what we need here is 2 things: 1) a notice, like we already have for the 1st arg: md5() expects parameter 2 to be bool, string given 2) strict checking $binary === true, not $binary == true Test script: --------------- $binary = 'hello'; echo md5( 'abc', $binary ); Expected result: ---------------- 1) a notice, like we already have for the 1st arg: md5() expects parameter 2 to be bool, string given 2) strict checking $binary === true, not $binary == true so we would get a hex md5 not a binary in this example Actual result: -------------- binary md5 -- Edit bug report at https://bugs.php.net/bug.php?id=81546&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81546&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81546&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81546&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81546&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81546&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81546&r=support Expected behavior: https://bugs.php.net/fix.php?id=81546&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81546&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81546&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81546&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81546&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81546&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81546&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81546&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81546&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81546&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81546&r=mysqlcfg

« previous php.bugs (#237295) next »