Bug #80870 [NEW]: base64_decode: Concatenated base64 blocks are corrupted

From: Date: Mon, 15 Mar 2021 20:28:36 +0000
Subject: Bug #80870 [NEW]: base64_decode: Concatenated base64 blocks are corrupted
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232755@lists.php.net to get a copy of this message
From:             bugs at jth dot net
Operating system: Linux
PHP version:      7.4.16
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:base64_decode: Concatenated base64 blocks are corrupted

Description:
------------
When decoding a string containing two or more base64 blocks with line
feeds in the base64 text the latter blocks are corrupted.

This may occur as input from an email generated by some mail programs.

Test script:
---------------
$s1 = base64_encode("Line nr 1 bcdefg\n");
$s2 = base64_encode("Line nr 2 \n");
$str = $s1."\n".$s2;
echo $str
echo base64_decode($str);



Expected result:
----------------
TGluZSBuciAxIGJjZGVmZwo=
TGluZSBuciAyIAo=

Line nr 1 bcdefg
Line nr 2 




Actual result:
--------------
Result:
TGluZSBuciAxIGJjZGVmZwo=
TGluZSBuciAyIAo=

Line nr 1 bcdefg
(corrupted text)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=80870&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=80870&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=80870&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=80870&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=80870&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=80870&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=80870&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=80870&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=80870&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=80870&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=80870&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80870&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=80870&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=80870&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=80870&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=80870&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=80870&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=80870&r=mysqlcfg


Thread (19 messages)

« previous php.bugs (#232755) next »