PHP :: Bug #68532 :: convert.base64-encode omits padding bytes

Bug #68532 convert.base64-encode omits padding bytes
Submitted: 2014-12-01 12:42 UTC Modified: 2015-08-19 20:06 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: blaesius at krumedia dot de Assigned: jpauli (profile)
Status: Closed Package: Streams related
PHP Version: 5.6.3 OS: Debian 8
Private report: No CVE-ID: None

 [2014-12-01 12:42 UTC] blaesius at krumedia dot de

Description:
------------
When using a memory stream and the read filter "convert.base64-encode" the last character is missing from the output if the base64 conversion needs padding bytes.
This doesn't happen when using a file.

Test script:
---------------
$testString = 'test';
$stream = fopen('php://memory','r+');
fwrite($stream, $testString);
rewind($stream);
$filter = stream_filter_append($stream, 'convert.base64-encode');
echo "memoryStream = " . stream_get_contents($stream).PHP_EOL;


$fileStream = fopen(__DIR__.'/base64test.txt','w+');
fwrite($fileStream , $testString);
rewind($fileStream );
$filter = stream_filter_append($fileStream , 'convert.base64-encode');
echo "fileStream = " . stream_get_contents($fileStream ).PHP_EOL;


Expected result:
----------------
memoryStream = dGVzdA==
fileStream = dGVzdA==


Actual result:
--------------
memoryStream = dGVz
fileStream = dGVzdA==


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

 [2014-12-12 16:05 UTC] jpauli@php.net

-Assigned To: +Assigned To: jpauli

 [2014-12-12 16:05 UTC] jpauli@php.net

The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

This has been merged against 5.5 and up

 [2015-08-19 19:35 UTC] mrubinsk at horde dot org

This bug appears to have regressed, at least in PHP 5.6.12.

The original test case posted with this bug report shows the same broken behavior when tested in 5.6.12.

 [2015-08-19 19:54 UTC] mrubinsk at horde dot org

Hm. It appears to work correctly on 3v41.org. Perhaps it's a bug in the debian package:

echo phpversion() . "\r";
$testString = 'test';
$stream = fopen('php://memory','r+');
fwrite($stream, $testString);
rewind($stream);
$filter = stream_filter_append($stream, 'convert.base64-encode');
echo "memoryStream = " . stream_get_contents($stream).PHP_EOL;


$fileStream = fopen('/tmp/base64test.txt','w+');
fwrite($fileStream , $testString);

Results:

5.6.12-1+deb.sury.org~trusty+1
memoryStream = dGVz
fileStream = dGVzdA==