2006-03-24 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
authorSimon Josefsson <simon@josefsson.org>
Fri, 24 Mar 2006 12:36:06 +0000 (12:36 +0000)
committerSimon Josefsson <simon@josefsson.org>
Fri, 24 Mar 2006 12:36:06 +0000 (12:36 +0000)
* base64.c (base64_encode): Do not read past end of array with
unsanitized input on systems with CHAR_BIT > 8.

lib/ChangeLog
lib/base64.c

index fed0610..75a0866 100644 (file)
@@ -1,3 +1,8 @@
+2006-03-24  Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+       * base64.c (base64_encode): Do not read past end of array with
+       unsanitized input on systems with CHAR_BIT > 8.
+
 2006-03-16  Paul Eggert  <eggert@cs.ucla.edu>
 
        * regex.h (regoff_t) [defined _REGEX_LARGE_OFFSETS]:
index 7682f85..1fe719c 100644 (file)
@@ -74,7 +74,7 @@ base64_encode (const char *restrict in, size_t inlen,
 
   while (inlen && outlen)
     {
-      *out++ = b64str[to_uchar (in[0]) >> 2];
+      *out++ = b64str[(to_uchar (in[0]) >> 2) & 0x3f];
       if (!--outlen)
        break;
       *out++ = b64str[((to_uchar (in[0]) << 4)