Fix error handling in sync_helper() and imap_sync_mailbox(). (closes #3817)
authorKevin McCarthy <kevin@8t8.us>
Sat, 26 Mar 2016 22:45:18 +0000 (15:45 -0700)
committerKevin McCarthy <kevin@8t8.us>
Sat, 26 Mar 2016 22:45:18 +0000 (15:45 -0700)
commitf38bcb36247c98ba26787feaa27d1f7b1f997a74
tree651f2c4902366d15b241598db5f1131a1f523d21
parent7069c5101d6bade329ad6d693509d0e5b6fd144b
Fix error handling in sync_helper() and imap_sync_mailbox(). (closes #3817)

This patch is based on the one Richard Russon found in the Fedora package.

If an error occurs during one of the imap_exec() calls in
imap_sync_mailbox(), the mailbox could end up being closed.  This
would cause idata->ctx to be NULL.  Add a check in sync_helper() for
the case where idata->ctx == NULL.

In imap_sync_mailbox(), check the return value of sync_helper().  To
keep the code simple, change rc from being the sum of the calls to the
bitwise-OR of the calls.  (We only need to know if a single flag needs
to be updated, and bitwise-OR will detect negatives.)

Below the calls to sync_helper(), if the call to imap_exec() fails,
make sure rc is set to -1.
imap/imap.c