diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-08-19 08:25:24 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-08-19 08:25:24 +0000 |
commit | 031fdede380670b32bc0689ac1da448261afaa40 (patch) | |
tree | 026df2f66c359335ed1dd76587c1748b66b6d1a3 | |
parent | 2c73885ba907a831d7989c7645abd4807565c0f6 (diff) |
made error check of IMAP4 fetch more strict.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@493 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ChangeLog.ja | 5 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | src/imap.c | 12 | ||||
-rw-r--r-- | src/recv.c | 20 |
5 files changed, 30 insertions, 14 deletions
@@ -1,5 +1,10 @@ 2005-08-19 + * src/recv.c + src/imap.c: made error check more strict. + +2005-08-19 + * src/socket.c: fd_write_all(): use fd_write() instead of directly using write() (fixes IMAP4 on win32). diff --git a/ChangeLog.ja b/ChangeLog.ja index a2c7648e..57d57992 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,5 +1,10 @@ 2005-08-19 + * src/recv.c + src/imap.c: エラーチェックをより正確にした。 + +2005-08-19 + * src/socket.c: fd_write_all(): write() を直接使わずに fd_write() を 使用するようにした(win32 上の IMAP4 を修正)。 diff --git a/configure.in b/configure.in index d0e0b788..cab78143 100644 --- a/configure.in +++ b/configure.in @@ -9,7 +9,7 @@ MINOR_VERSION=1 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION= +EXTRA_VERSION=+svn VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION dnl set $target @@ -3436,6 +3436,7 @@ static gint imap_cmd_fetch(IMAPSession *session, guint32 uid, gchar *cur_pos; gchar size_str[32]; glong size_num; + gint ret; g_return_val_if_fail(filename != NULL, IMAP_ERROR); @@ -3471,9 +3472,11 @@ static gint imap_cmd_fetch(IMAPSession *session, guint32 uid, g_free(buf); - if (recv_bytes_write_to_file(SESSION(session)->sock, - size_num, filename) != 0) - return IMAP_ERROR; + if ((ret = recv_bytes_write_to_file(SESSION(session)->sock, + size_num, filename)) != 0) { + if (ret == -2) + return IMAP_SOCKET; + } if (imap_cmd_gen_recv(session, &buf) != IMAP_SUCCESS) return IMAP_ERROR; @@ -3486,6 +3489,9 @@ static gint imap_cmd_fetch(IMAPSession *session, guint32 uid, ok = imap_cmd_ok(session, NULL); + if (ret != 0) + return IMAP_ERROR; + return ok; } @@ -76,8 +76,7 @@ gint recv_bytes_write_to_file(SockInfo *sock, glong size, const gchar *filename) if ((fp = g_fopen(filename, "wb")) == NULL) { FILE_OP_ERROR(filename, "fopen"); - recv_write(sock, NULL); - return -1; + return recv_bytes_write(sock, size, NULL); } if (change_file_mode_rw(fp, filename) < 0) @@ -191,12 +190,11 @@ gint recv_bytes_write(SockInfo *sock, glong size, FILE *fp) while ((cur = memchr(prev, '\r', size - (prev - buf))) != NULL) { if (cur == buf + size - 1) break; - if (fwrite(prev, sizeof(gchar), cur - prev, fp) == EOF || - fwrite("\n", sizeof(gchar), 1, fp) == EOF) { + if (fp && (fwrite(prev, sizeof(gchar), cur - prev, fp) == EOF || + fwrite("\n", sizeof(gchar), 1, fp) == EOF)) { perror("fwrite"); g_warning(_("Can't write to file.\n")); - g_free(buf); - return -1; + fp = NULL; } if (*(cur + 1) == '\n') @@ -207,15 +205,17 @@ gint recv_bytes_write(SockInfo *sock, glong size, FILE *fp) if (prev - buf >= size) break; } - if (prev - buf < size && fwrite(buf, sizeof(gchar), - size - (prev - buf), fp) == EOF) { + if (prev - buf < size && fp && + fwrite(buf, sizeof(gchar), size - (prev - buf), fp) == EOF) { perror("fwrite"); g_warning(_("Can't write to file.\n")); - g_free(buf); - return -1; + fp = NULL; } g_free(buf); + + if (!fp) return -1; + return 0; } |