aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-09-13 05:41:52 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-09-13 05:41:52 +0000
commitd7ea96a449049db7de8e92d135b1d961c523a351 (patch)
treeac14ce6a352fc29baeb03af5c9b8f75d76f349ab
parentd7a5fbadd02bc9e47459c6280cdfd20d18620803 (diff)
session.c: added extra error checking when writing to buffer.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1155 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.ja7
-rw-r--r--libsylph/procmsg.c9
-rw-r--r--libsylph/session.c7
4 files changed, 26 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index fbbeaadc..3f684cd6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2006-09-13
+ * libsylph/procmsg.c: procmsg_read_cache(): fixed crash when reading
+ a corrupted cache data.
+ * libsylph/session.c: session_read_data_as_file_cb(): fflush buffer
+ and check error before rewind().
+
+2006-09-13
+
* libsylph/procmime.c: procmime_decode_content(): fflush temporary
file and check errors.
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 4b8800ff..cb40820f 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,12 @@
2006-09-13
+ * libsylph/procmsg.c: procmsg_read_cache(): 壊れたキャッシュデータを
+ 読んだときにクラッシュするのを修正。
+ * libsylph/session.c: session_read_data_as_file_cb(): rewind() の前に
+ バッファを fflush し、エラーをチェックするようにした。
+
+2006-09-13
+
* libsylph/procmime.c: procmime_decode_content(): 一時ファイルを
fflush し、エラーをチェックするようにした。
diff --git a/libsylph/procmsg.c b/libsylph/procmsg.c
index 13141f50..37546154 100644
--- a/libsylph/procmsg.c
+++ b/libsylph/procmsg.c
@@ -156,10 +156,11 @@ gint procmsg_read_cache_data_str(FILE *fp, gchar **str)
#define READ_CACHE_DATA(data, fp) \
{ \
if (procmsg_read_cache_data_str(fp, &data) < 0) { \
+ g_warning("Cache data is corrupted\n"); \
procmsg_msginfo_free(msginfo); \
procmsg_msg_list_free(mlist); \
- mlist = NULL; \
- break; \
+ fclose(fp); \
+ return NULL; \
} \
}
@@ -171,8 +172,8 @@ gint procmsg_read_cache_data_str(FILE *fp, gchar **str)
g_warning("Cache data is corrupted\n"); \
procmsg_msginfo_free(msginfo); \
procmsg_msg_list_free(mlist); \
- mlist = NULL; \
- break; \
+ fclose(fp); \
+ return NULL; \
} else \
n = idata; \
}
diff --git a/libsylph/session.c b/libsylph/session.c
index 8e7cd835..b8b77aff 100644
--- a/libsylph/session.c
+++ b/libsylph/session.c
@@ -839,6 +839,13 @@ static gboolean session_read_data_as_file_cb(SockInfo *source,
}
session->read_data_pos += write_len;
+ if (fflush(session->read_data_fp) == EOF) {
+ perror("fflush");
+ g_warning("session_read_data_as_file_cb: "
+ "writing data to file failed\n");
+ session->state = SESSION_ERROR;
+ return FALSE;
+ }
rewind(session->read_data_fp);
/* callback */