isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 06ccac1fdd0cd2aa27f04435b4cd29a6588939f1
parent 121ce76e46b6325b9475c3bc5a3b7b5028b40d39
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Sun, 20 Mar 2011 13:45:42 +0100

always use return value from get_cmd_result()

once we have callback-based error reporting, this will ensure that we
don't operate on invalidated data structures.

Diffstat:
Msrc/drv_imap.c | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/drv_imap.c b/src/drv_imap.c @@ -503,7 +503,8 @@ v_submit_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd, char buf[1024]; while (ctx->literal_pending) - get_cmd_result( ctx, 0 ); + if (get_cmd_result( ctx, 0 ) == RESP_BAD) + goto bail; if (!cmd) cmd = new_imap_cmd(); @@ -625,12 +626,14 @@ drain_imap_replies( imap_store_t *ctx ) } */ -static void +static int process_imap_replies( imap_store_t *ctx ) { while (ctx->num_in_progress > max_in_progress || socket_pending( &ctx->buf.sock )) - get_cmd_result( ctx, 0 ); + if (get_cmd_result( ctx, 0 ) == RESP_BAD) + return RESP_BAD; + return RESP_OK; } static int @@ -1616,8 +1619,7 @@ imap_flags_helper( imap_store_t *ctx, int uid, char what, int flags) buf[imap_make_flags( flags, buf )] = 0; if (!submit_imap_cmd( ctx, 0, "UID STORE %d %cFLAGS.SILENT %s", uid, what, buf )) return DRV_STORE_BAD; - process_imap_replies( ctx ); - return DRV_OK; + return process_imap_replies( ctx ) == RESP_BAD ? DRV_STORE_BAD : DRV_OK; } static int