// Purpose: implementation of BASE64 encoding/decoding functions
// Author: Charles Reimers, Vadim Zeitlin
// Created: 2007-06-18
-// RCS-ID: $Id$
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// undo the bit shifting done during encoding
*dst++ = in[0] << 2 | in[1] >> 4;
- *dst++ = in[1] << 4 | in[2] >> 2;
- *dst++ = in[2] << 6 | in[3];
+
+ // be careful to not overwrite the output buffer with NUL pad
+ // bytes
+ if ( padLen != 2 )
+ {
+ *dst++ = in[1] << 4 | in[2] >> 2;
+ if ( !padLen )
+ *dst++ = in[2] << 6 | in[3];
+ }
}
n = 0;