summaryrefslogtreecommitdiff
path: root/ext/standard/base64.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2009-01-21 15:38:37 +0000
committerIlia Alshanetsky <iliaa@php.net>2009-01-21 15:38:37 +0000
commitbd9ad75f416825f9b670dd30bd7f861a2c13bf7d (patch)
treecdb9e0b7c6ef825a489ac3bb9198917ce8a8c853 /ext/standard/base64.c
parent9942dde8bd6ce21493b2f253bb9c9a45684ac253 (diff)
downloadphp-git-bd9ad75f416825f9b670dd30bd7f861a2c13bf7d.tar.gz
Fixed bug #47174 (base64_decode() interprets pad char in mid string as
terminator)
Diffstat (limited to 'ext/standard/base64.c')
-rw-r--r--ext/standard/base64.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/standard/base64.c b/ext/standard/base64.c
index 62083b3476..9b835409d1 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 */