Edit report at http://bugs.php.net/bug.php?id=53566&edit=1

 ID:                 53566
 Updated by:         cataphr...@php.net
 Reported by:        jjj17 at yandex dot ru
-Summary:            php 5.2.14
+Summary:            base64_decode gives wrong result when added a \0
                     octet to the unencoded data
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Unknown/Other Function
 PHP Version:        5.2.16
 Block user comment: N
 Private report:     N

 New Comment:

You are corrupting the encoding data, namely adding an octet that isn't
allowed in base 64, why would you expect the correct result?...



Furthermore, basse 64 encoded strings do not have to end in the padding
character.



Note you can use base64_decode($aa.'\\0', true); to force the function
to fail when the input is invalid.


Previous Comments:
------------------------------------------------------------------------
[2010-12-17 21:58:24] jjj17 at yandex dot ru

Description:
------------
---

>From manual page: http://www.php.net/function.base64-decode#Return
Values

---



If a string to decode has wrong bytes at the end of the string, which
normally ends with "=", then base64_decode() returns a wrong result of
decode.



Test script:
---------------
<?php

$a = "qwertyui";

$aa = base64_encode($a);

echo base64_decode($aa.'\\0');

?>

Expected result:
----------------
qwertyui

Actual result:
--------------
qwertyui4


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53566&edit=1

Reply via email to