diff -up php-5.2.17/ext/standard/base64.c.bug-55273 php-5.2.17/ext/standard/base64.c --- php-5.2.17/ext/standard/base64.c.bug-55273 2012-01-12 10:45:40.000000000 +0700 +++ php-5.2.17/ext/standard/base64.c 2012-01-12 10:47:32.000000000 +0700 @@ -154,7 +154,15 @@ PHPAPI unsigned char *php_base64_decode_ /* run through the whole string, converting as we go */ while ((ch = *current++) != '\0' && length-- > 0) { if (ch == base64_pad) { - if (*current != '=' && (i % 4) == 1) { + if (*current != '=' && ((i % 4) == 1 || (strict && length > 0))) { + if ((i % 4) != 1) { + while (isspace(*(++current))) { + continue; + } + if (*current == '\0') { + continue; + } + } efree(result); return NULL; }