]> granicus.if.org Git - php/commitdiff
Fixed a bug of the base64 decoder that a sequence of intervening
authorMoriyoshi Koizumi <moriyoshi@php.net>
Sun, 12 Jan 2003 21:05:22 +0000 (21:05 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Sun, 12 Jan 2003 21:05:22 +0000 (21:05 +0000)
characters that are supposed to be ignored by the decoder cause output
corruption.

ext/standard/filters.c

index be7346fc2e6408f458171fb788c43ef5a836b676..9966305c70fc3b2573d1644891000f6a718f7d70 100644 (file)
@@ -526,9 +526,6 @@ static php_conv_err_t php_conv_base64_decode_convert(php_conv_base64_decode *ins
                }
                if ((pack_bcnt | ustat) == 0) {
                        if (ocnt < 1) {
-                               urem |= (pack << urem_nbits);
-                               urem_nbits += 8;
-
                                err = PHP_CONV_ERR_TOO_BIG;
                                break;
                        }
@@ -539,6 +536,14 @@ static php_conv_err_t php_conv_base64_decode_convert(php_conv_base64_decode *ins
                }
        }
 
+       if (urem_nbits >= pack_bcnt) {
+               urem |= (pack << (urem_nbits - pack_bcnt));
+               urem_nbits += (nbitsof_pack - pack_bcnt);
+       } else {
+               urem |= (pack >> (pack_bcnt - urem_nbits));
+               urem_nbits += (nbitsof_pack - pack_bcnt);
+       }
+
        inst->urem = urem;
        inst->urem_nbits = urem_nbits;
        inst->ustat = ustat;