php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
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

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-12-12 16:04 UTC] jpauli@php.net
Automatic comment on behalf of php@mcq8.be
Revision: http://git.php.net/?p=php-src.git;a=commit;h=86f18755362b594c519ccde37c3b3f98158b591e
Log: Fix bug #68532: convert.base64-encode omits padding bytes
 [2014-12-12 16:04 UTC] jpauli@php.net
-Status: Open +Status: Closed
 [2014-12-12 16:04 UTC] jpauli@php.net
Automatic comment on behalf of php@mcq8.be
Revision: http://git.php.net/?p=php-src.git;a=commit;h=86f18755362b594c519ccde37c3b3f98158b591e
Log: Fix bug #68532: convert.base64-encode omits padding bytes
 [2014-12-12 16:04 UTC] jpauli@php.net
Automatic comment on behalf of php@mcq8.be
Revision: http://git.php.net/?p=php-src.git;a=commit;h=86f18755362b594c519ccde37c3b3f98158b591e
Log: Fix bug #68532: convert.base64-encode omits padding bytes
 [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
 [2014-12-13 19:23 UTC] ab@php.net
Automatic comment on behalf of php@mcq8.be
Revision: http://git.php.net/?p=php-src.git;a=commit;h=86f18755362b594c519ccde37c3b3f98158b591e
Log: Fix bug #68532: convert.base64-encode omits padding bytes
 [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:41 UTC] requinix@php.net
@mrubinsk:
I looks to be behaving correctly as of 5.6.5. https://3v4l.org/jr2Mi Can you be more specific about how/where it's failing?
 [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==
 [2015-08-19 20:06 UTC] requinix@php.net
Want to file a bug with the PPA? https://bugs.launchpad.net/~ondrej
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 02:01:28 2024 UTC