From 4de6cf41701eed5321139e0a7959477da290c169 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Wed, 10 Nov 2010 20:22:16 +0100 Subject: [PATCH] fix buffer overrun while converting charsets * DecodeSegment() didn't check whether one of the temporary buffers would be able to bear the transcoding results --- libcitadel/lib/stringbuf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libcitadel/lib/stringbuf.c b/libcitadel/lib/stringbuf.c index 5c538310f..ed17a0a0c 100644 --- a/libcitadel/lib/stringbuf.c +++ b/libcitadel/lib/stringbuf.c @@ -2850,6 +2850,8 @@ inline static void DecodeSegment(StrBuf *Target, *encoding = toupper(*encoding); if (*encoding == 'B') { /**< base64 */ + if (ConvertBuf2->BufSize < ConvertBuf->BufUsed) + IncreaseBuf(ConvertBuf2, 0, ConvertBuf->BufUsed); ConvertBuf2->BufUsed = CtdlDecodeBase64(ConvertBuf2->buf, ConvertBuf->buf, ConvertBuf->BufUsed); @@ -2865,6 +2867,9 @@ inline static void DecodeSegment(StrBuf *Target, pos++; } + if (ConvertBuf2->BufSize < ConvertBuf->BufUsed) + IncreaseBuf(ConvertBuf2, 0, ConvertBuf->BufUsed); + ConvertBuf2->BufUsed = CtdlDecodeQuotedPrintable( ConvertBuf2->buf, ConvertBuf->buf, -- 2.30.2