From: Colin Leroy Date: Wed, 4 Nov 2015 21:40:32 +0000 (+0100) Subject: Make sure we don't run out of the output buffer. Maybe fixes bug #3557 X-Git-Tag: 3.13.1~67 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=d390fa07f5548f3173dd9cc13b233db5ce934c82;ds=sidebyside Make sure we don't run out of the output buffer. Maybe fixes bug #3557 --- diff --git a/src/codeconv.c b/src/codeconv.c index 42ac01c21..39e259fc6 100644 --- a/src/codeconv.c +++ b/src/codeconv.c @@ -155,10 +155,10 @@ void codeconv_set_strict(gboolean mode) static gint conv_jistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf) { const guchar *in = inbuf; - guchar *out = outbuf; + gchar *out = outbuf; JISState state = JIS_ASCII; - while (*in != '\0') { + while (*in != '\0' && (out - outbuf) > outlen - 3) { if (*in == ESC) { in++; if (*in == '$') { @@ -291,10 +291,10 @@ static gint conv_jis_hantozen(guchar *outbuf, guchar jis_code, guchar sound_sym) static gint conv_euctojis(gchar *outbuf, gint outlen, const gchar *inbuf) { const guchar *in = inbuf; - guchar *out = outbuf; + gchar *out = outbuf; JISState state = JIS_ASCII; - while (*in != '\0') { + while (*in != '\0' && (out - outbuf) < outlen - 3) { if (IS_ASCII(*in)) { K_OUT(); *out++ = *in++; @@ -380,9 +380,9 @@ static gint conv_euctojis(gchar *outbuf, gint outlen, const gchar *inbuf) static gint conv_sjistoeuc(gchar *outbuf, gint outlen, const gchar *inbuf) { const guchar *in = inbuf; - guchar *out = outbuf; + gchar *out = outbuf; - while (*in != '\0') { + while (*in != '\0' && (out - outbuf) < outlen - 3) { if (IS_ASCII(*in)) { *out++ = *in++; } else if (issjiskanji1(*in)) {