From c706c84c7f8b3991234852c9c3833a2c126e5d0a Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 21 Jan 2009 15:45:45 +0000 Subject: [PATCH] MFB: Fixed bug #47174 (base64_decode() interprets pad char in mid string as terminator) --- ext/standard/base64.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ext/standard/base64.c b/ext/standard/base64.c index 8fa2a923b9..2533442260 100644 --- a/ext/standard/base64.c +++ b/ext/standard/base64.c @@ -151,7 +151,14 @@ PHPAPI unsigned char *php_base64_decode_ex(const unsigned char *str, int length, /* run through the whole string, converting as we go */ while ((ch = *current++) != '\0' && length-- > 0) { - if (ch == base64_pad) break; + if (ch == base64_pad) { + if (*current != '=' && (i % 4) == 1) { + efree(result); + return NULL; + } + i++; + continue; + } ch = base64_reverse_table[ch]; if ((!strict && ch < 0) || ch == -1) { /* a space or some other separator character, we simply skip over */ -- 2.50.1