]> granicus.if.org Git - php/commitdiff
Fixed possible buffer overflow in php_base64_decode();
authorMoriyoshi Koizumi <moriyoshi@php.net>
Sun, 1 Dec 2002 02:44:50 +0000 (02:44 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Sun, 1 Dec 2002 02:44:50 +0000 (02:44 +0000)
# This bug doesn't appear to be harmful for now,
# so I won't merge it into branches...

ext/standard/base64.c

index 18f1e9c5328bf89717853761aa2640de62e11ce0..4fefd1bc54ea5d929350f52c81709cd10775fe74 100644 (file)
@@ -140,7 +140,7 @@ unsigned char *php_base64_decode(const unsigned char *str, int length, int *ret_
        }
 
        /* run through the whole string, converting as we go */
-       while ((ch = *current++) != '\0') {
+       while ((ch = *current++) != '\0' && length-- > 0) {
                if (ch == base64_pad) break;
 
            /* When Base64 gets POSTed, all pluses are interpreted as spaces.