diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-03-04 07:05:52 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-03-04 07:05:52 +0000 |
commit | bdcba0877a6b870e40dcca384ef08be78fd0e74e (patch) | |
tree | c65bebfd067e3aaea7f9614443670b3ddee0b543 /src/codeconv.c | |
parent | a80cf7559e18da4e89fae15c2ff10966b1983ffa (diff) |
fixed a buffer overflow bug.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@145 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/codeconv.c')
-rw-r--r-- | src/codeconv.c | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/src/codeconv.c b/src/codeconv.c index 36e158c0..0d494919 100644 --- a/src/codeconv.c +++ b/src/codeconv.c @@ -1541,54 +1541,46 @@ const gchar *conv_get_current_locale(void) return cur_locale; } -void conv_unmime_header_overwrite(gchar *str) -{ - gchar *buf; - gint buflen; - - buflen = strlen(str) * 2 + 1; - Xalloca(buf, buflen, return); - - if (conv_get_locale_charset() == C_EUC_JP) - conv_anytodisp(buf, buflen, str); - else - conv_localetodisp(buf, buflen, str); - - unmime_header(str, buf); -} - -void conv_unmime_header(gchar *outbuf, gint outlen, const gchar *str, - const gchar *default_encoding) +gchar *conv_unmime_header(const gchar *str, const gchar *default_encoding) { gchar *buf; gint buflen; + gchar *utf8_buf; if (is_ascii_str(str)) { - unmime_header(outbuf, str); - return; + buflen = strlen(str) * 6 + 1; + Xalloca(buf, buflen, return NULL); + unmime_header(buf, str); + return g_strdup(buf); } if (default_encoding) { - gchar *utf8_str; - - utf8_str = conv_codeset_strdup + utf8_buf = conv_codeset_strdup (str, default_encoding, CS_INTERNAL); - if (utf8_str) { - unmime_header(outbuf, utf8_str); - g_free(utf8_str); - return; + if (utf8_buf) { + buflen = strlen(utf8_buf) * 6 + 1; + Xalloca(buf, buflen, + { g_free(utf8_buf); return NULL; }); + unmime_header(buf, utf8_buf); + g_free(utf8_buf); + return g_strdup(buf); } } - buflen = strlen(str) * 2 + 1; - Xalloca(buf, buflen, return); + buflen = strlen(str) * 6 + 1; + Xalloca(utf8_buf, buflen, return NULL); if (conv_get_locale_charset() == C_EUC_JP) - conv_anytodisp(buf, buflen, str); + conv_anytodisp(utf8_buf, buflen, str); else - conv_localetodisp(buf, buflen, str); + conv_localetodisp(utf8_buf, buflen, str); + + buflen = strlen(utf8_buf) * 6 + 1; + Xalloca(buf, buflen, return NULL); + + unmime_header(buf, utf8_buf); - unmime_header(outbuf, buf); + return g_strdup(buf); } #define MAX_LINELEN 76 |