php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36106 Output of base64_decode differs between 5.0.4 and 5.1.2
Submitted: 2006-01-20 17:27 UTC Modified: 2006-01-20 19:43 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: schapht at verizon dot net Assigned:
Status: Not a bug Package: URL related
PHP Version: 5.1.2 OS: CentOS 4.1
Private report: No CVE-ID: None
 [2006-01-20 17:27 UTC] schapht at verizon dot net
Description:
------------
The decoding behavior of base64_decode seems to have changed between 5.0.4 and 5.1.2.

A simple case like 'SGVsbG8gV29ybGQh' (Hello World!) works, bu this more complex case (an already encrypted string) breaks.

NOTE: The reason I'm feeding the $complexString output into md5 is that is contains many unprintable characters because the base64_encrypted string is an already blowfish-encrypted string.

Reproduce code:
---------------
<?php

$string = "B 5mvYwuEVli6vkhSUH9dRwpxUWe6LdXQOV8PTak0nlftEZ8lMwnib7 Z SJQt5gXtf1FirG3p8ryIM6JBVVBRH9ceS5jXkCvi4Y4X8HAAIWyujb1WHOpDIItQ1ixLul1ylezCkBZC5iGDlH/IchuPUMtvnoP9FeOy5CwQ==";
echo md5(base64_decode($string));
echo "\n";
?>

Expected result:
----------------
[schapht@dev ~]$ /usr/local/src/php-5.1.2/sapi/cli/php test.php
Easy    : Hello World!
Complex (fed through md5): 10a36e3377f55d981af2b547971ff3da
[schapht@dev ~]$ /usr/local/src/php-5.0.4/sapi/cli/php test.php
Easy    : Hello World!
Complex (fed through md5): 10a36e3377f55d981af2b547971ff3da

Actual result:
--------------
[schapht@dev ~]$ /usr/local/src/php-5.1.2/sapi/cli/php test.php
Easy    : Hello World!
Complex (fed through md5): 52054f13d2bc7b82cd55bcb37c02b32b
[schapht@dev ~]$ /usr/local/src/php-5.0.4/sapi/cli/php test.php
Easy    : Hello World!
Complex (fed through md5): 10a36e3377f55d981af2b547971ff3da

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-20 17:28 UTC] schapht at verizon dot net
Sorry... Above code is incorrect, the following is the script under test:

<?php

$easyString = "SGVsbG8gV29ybGQh";
$complexString = "B 5mvYwuEVli6vkhSUH9dRwpxUWe6LdXQOV8PTak0nlftEZ8lMwnib7 Z SJQt5gXtf1FirG3p8ryIM6JBVVBRH9ceS5jXkCvi4Y4X8HAAIWyujb1WHOpDIItQ1ixLul1ylezCkBZC5iGDlH/IchuPUMtvnoP9FeOy5CwQ==";

echo "Easy    : ". base64_decode($easyString) ."\n";
echo "Complex (fed through md5): ". md5(base64_decode($complexString)) ."\n";
?>
 [2006-01-20 19:28 UTC] schapht at verizon dot net
I have report from a ##php user that 4.4.1 follows the same behavior as 5.1.2.  I wonder if it was something that got fixed in 5.0.4, then somehow lost.
 [2006-01-20 19:43 UTC] tony2001@php.net
See bug #34214.
In 5.0.4 base64_decode() produces bool(false) with your code and this is fixed in newer releases.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 06:01:28 2024 UTC