2006-03-24 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
[pspp] / lib / base64.c
index 2a68952d7c248599fef0b46f72f29c3d32d7ba01..1fe719c95c010d286b8318f9628ccb2e34bd0611 100644 (file)
@@ -1,5 +1,6 @@
 /* base64.c -- Encode binary data using printable characters.
-   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2004, 2005, 2006 Free Software
+   Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -73,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)