aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog7
-rw-r--r--camel/camel-mime-utils.c11
-rw-r--r--camel/providers/imap/camel-imap-folder.c3
3 files changed, 14 insertions, 7 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 12b2382d4f..2a102d280d 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,12 @@
2002-08-07 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-mime-utils.c (header_encode_param): Oops - outbuf pointed
+ to alloca'd memory but we were g_free'ing it after using
+ it. Instead use g_malloc for this outbuf buffer since it may be
+ kinda large. Also don't depend on a single byte to nul-terminate
+ the outbuf buffer so as to be safe with charsets such as UCS2 and
+ UCS4, instead keep a pointer to the end of the buffer.
+
* providers/imap/camel-imap-folder.c (parse_fetch_response): Only
add the stream to the gdatalist if it is non-NULL.
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index e594a43ed4..3dc31f04d3 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -2929,6 +2929,7 @@ header_encode_param (const unsigned char *in, gboolean *encoded)
{
register const unsigned char *inptr = in;
unsigned char *outbuf = NULL;
+ const unsigned char *inend;
iconv_t cd = (iconv_t) -1;
const char *charset;
char *outstr;
@@ -2985,14 +2986,15 @@ header_encode_param (const unsigned char *in, gboolean *encoded)
if (cd == (iconv_t) -1) {
charset = "UTF-8";
inptr = in;
+ inend = inptr + strlen (in);
} else {
size_t inleft, outleft;
const char *inbuf;
char *outptr;
inleft = (inptr - in);
- outleft = inleft * 6 + 16 + 1;
- outptr = outbuf = alloca (outleft);
+ outleft = inleft * 6 + 20;
+ outptr = outbuf = g_malloc (outleft);
inbuf = in;
if (e_iconv (cd, &inbuf, &inleft, &outptr, &outleft) == (size_t) -1) {
@@ -3003,16 +3005,15 @@ header_encode_param (const unsigned char *in, gboolean *encoded)
e_iconv_close (cd);
- *outptr = '\0';
-
inptr = outbuf;
+ inend = outptr;
}
/* FIXME: set the 'language' as well, assuming we can get that info...? */
out = g_string_new ("");
g_string_sprintfa (out, "%s''", charset);
- while (inptr && *inptr) {
+ while (inptr < inend) {
unsigned char c = *inptr++;
/* FIXME: make sure that '\'', '*', and ';' are also encoded */
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index fc08efc5dc..05867b0629 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -2415,8 +2415,7 @@ camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid,
CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock);
if (!stream) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
- _("Could not find message body in FETCH "
- "response."));
+ _("Could not find message body in FETCH response."));
} else {
camel_object_ref (CAMEL_OBJECT (stream));
g_datalist_clear (&fetch_data);