Never overflow the output buffer in wxBase64Decode().
Don't write extra NUL bytes obtained by decoding the padding at the end of input into the output buffer as there may be not enough place in it for them. And in any case the buffer is not (always) NUL-terminated as no NUL bytes are obtained in absence of padding, so it's better to never terminate it for consistency. Closes #11101. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61753 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -187,8 +187,15 @@ wxBase64Decode(void *dst_, size_t dstLen,
|
||||
|
||||
// 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;
|
||||
|
||||
Reference in New Issue
Block a user