dovecot: Charset translation fixes
dovecot at dovecot.org
dovecot at dovecot.org
Sun Nov 18 10:56:25 EET 2007
details: http://hg.dovecot.org/dovecot/rev/ea4d3778c99b
changeset: 6832:ea4d3778c99b
user: Timo Sirainen <tss at iki.fi>
date: Sun Nov 18 10:56:21 2007 +0200
description:
Charset translation fixes
diffstat:
1 file changed, 17 insertions(+), 13 deletions(-)
src/lib-mail/message-decoder.c | 30 +++++++++++++++++-------------
diffs (41 lines):
diff -r ddf393049f28 -r ea4d3778c99b src/lib-mail/message-decoder.c
--- a/src/lib-mail/message-decoder.c Sun Nov 18 10:16:48 2007 +0200
+++ b/src/lib-mail/message-decoder.c Sun Nov 18 10:56:21 2007 +0200
@@ -183,20 +183,24 @@ static void translation_buf_decode(struc
const unsigned char **data, size_t *size)
{
unsigned char trans_buf[MAX_TRANSLATION_BUF_SIZE+1];
- size_t pos, skip;
-
- /* @UNSAFE */
+ unsigned int data_wanted, skip;
+ size_t trans_size;
+
+ /* @UNSAFE: move the previously untranslated bytes to trans_buf
+ and see if we have now enough data to get the next character
+ translated */
memcpy(trans_buf, ctx->translation_buf, ctx->translation_size);
- skip = sizeof(trans_buf) - ctx->translation_size;
- if (skip > *size)
- skip = *size;
- memcpy(trans_buf + ctx->translation_size, data, skip);
-
- pos = *size;
- (void)charset_to_utf8(ctx->charset_trans, *data, &pos, ctx->buf2);
-
- i_assert(pos > ctx->translation_size);
- skip = (ctx->translation_size + skip) - pos;
+ data_wanted = sizeof(trans_buf) - ctx->translation_size;
+ if (data_wanted > *size)
+ data_wanted = *size;
+ memcpy(trans_buf + ctx->translation_size, *data, data_wanted);
+
+ trans_size = ctx->translation_size + data_wanted;
+ (void)charset_to_utf8(ctx->charset_trans, trans_buf,
+ &trans_size, ctx->buf2);
+
+ i_assert(trans_size > ctx->translation_size);
+ skip = trans_size - ctx->translation_size;
i_assert(*size >= skip);
*data += skip;
More information about the dovecot-cvs
mailing list