aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-04-04 08:31:41 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-04-04 08:31:41 +0000
commitaaa2243cef404dde866f6ff7f67fe885981057d4 (patch)
treef529a4f7404c1db5cc5739bb2bc644328f2cf081
parent1c58ef8447abe335761f0a26b6a2e4ddb11dbf31 (diff)
procmime_scan_multipart_message(): use heap memory instead of stack for read buffer, and increased the max recursion level to 64.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1593 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.ja6
-rw-r--r--libsylph/procmime.c25
3 files changed, 31 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 50c5b359..26e062d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2007-04-04
+ * libsylph/procmime.c: procmime_scan_multipart_message(): use heap
+ memory instead of stack for read buffer, and increased the max
+ recursion level to 64.
+
+2007-04-04
+
* src/inc.c: inc_is_active(): also check for session queue.
inc_cancel_all(): really cancel all sessions.
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 899ea30e..15d5f803 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,11 @@
2007-04-04
+ * libsylph/procmime.c: procmime_scan_multipart_message(): 読み込み
+ バッファにスタックでなくヒープメモリを使用するようにし、再帰
+ レベルの上限を64に上げた。
+
+2007-04-04
+
* src/inc.c: inc_is_active(): セッションキューもチェックする
ようにした。
inc_cancel_all(): 本当にすべてのセッションをキャンセルする
diff --git a/libsylph/procmime.c b/libsylph/procmime.c
index 243a0474..de5c92ba 100644
--- a/libsylph/procmime.c
+++ b/libsylph/procmime.c
@@ -40,6 +40,8 @@
#include "utils.h"
#include "prefs_common.h"
+#define MAX_MIME_LEVEL 64
+
static GHashTable *procmime_get_mime_type_table (void);
static GList *procmime_get_mime_type_list (const gchar *file);
@@ -205,7 +207,7 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp)
gchar *p;
gchar *boundary;
gint boundary_len = 0;
- gchar buf[BUFFSIZE];
+ gchar *buf;
glong fpos, prev_fpos;
g_return_if_fail(mimeinfo != NULL);
@@ -218,15 +220,20 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp)
}
g_return_if_fail(fp != NULL);
+ buf = g_malloc(BUFFSIZE);
+
boundary = mimeinfo->boundary;
if (boundary) {
boundary_len = strlen(boundary);
/* look for first boundary */
- while ((p = fgets(buf, sizeof(buf), fp)) != NULL)
+ while ((p = fgets(buf, BUFFSIZE, fp)) != NULL)
if (IS_BOUNDARY(buf, boundary, boundary_len)) break;
- if (!p) return;
+ if (!p) {
+ g_free(buf);
+ return;
+ }
} else if (mimeinfo->parent && mimeinfo->parent->boundary) {
boundary = mimeinfo->parent->boundary;
boundary_len = strlen(boundary);
@@ -234,9 +241,12 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp)
if ((fpos = ftell(fp)) < 0) {
perror("ftell");
+ g_free(buf);
return;
}
+ debug_print("level = %d\n", mimeinfo->level);
+
for (;;) {
MimeInfo *partinfo;
gboolean eom = FALSE;
@@ -256,7 +266,8 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp)
mimeinfo->sub = sub = procmime_scan_mime_header(fp);
if (!sub) break;
- debug_print("message/rfc822 part found\n");
+ debug_print("message/rfc822 part (content-type: %s)\n",
+ sub->content_type);
sub->level = mimeinfo->level + 1;
sub->parent = mimeinfo->parent;
sub->main = mimeinfo;
@@ -276,14 +287,14 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp)
if (partinfo->mime_type == MIME_MULTIPART ||
partinfo->mime_type == MIME_MESSAGE_RFC822) {
- if (partinfo->level < 8)
+ if (partinfo->level < MAX_MIME_LEVEL)
procmime_scan_multipart_message(partinfo, fp);
}
/* look for next boundary */
buf[0] = '\0';
is_base64 = partinfo->encoding_type == ENC_BASE64;
- while ((p = fgets(buf, sizeof(buf), fp)) != NULL) {
+ while ((p = fgets(buf, BUFFSIZE, fp)) != NULL) {
if (IS_BOUNDARY(buf, boundary, boundary_len)) {
if (buf[2 + boundary_len] == '-' &&
buf[2 + boundary_len + 1] == '-')
@@ -334,6 +345,8 @@ void procmime_scan_multipart_message(MimeInfo *mimeinfo, FILE *fp)
if (eom) break;
}
+
+ g_free(buf);
}
void procmime_scan_encoding(MimeInfo *mimeinfo, const gchar *encoding)