From 3363ad0f11bd33401ba6dbbec17cf497de7dab4b Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sat, 23 Mar 2013 10:34:51 +0100 Subject: [PATCH] fix crashes in imap_open_store() error paths it's not a good idea to invoke imap_open_store_bail() twice, either ... --- src/drv_imap.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index 378c351..c790c41 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -1322,9 +1322,9 @@ imap_open_store_greeted( imap_store_t *ctx ) static void imap_open_store_p2( imap_store_t *ctx, struct imap_cmd *cmd ATTR_UNUSED, int response ) { - if (response != RESP_OK) + if (response == RESP_NO) imap_open_store_bail( ctx ); - else + else if (response == RESP_OK) imap_open_store_authenticate( ctx ); } @@ -1363,9 +1363,9 @@ imap_open_store_authenticate( imap_store_t *ctx ) static void imap_open_store_authenticate_p2( imap_store_t *ctx, struct imap_cmd *cmd ATTR_UNUSED, int response ) { - if (response != RESP_OK) + if (response == RESP_NO) imap_open_store_bail( ctx ); - else + else if (response == RESP_OK) socket_start_tls( &ctx->conn, imap_open_store_tlsstarted2 ); } @@ -1383,9 +1383,9 @@ imap_open_store_tlsstarted2( int ok, void *aux ) static void imap_open_store_authenticate_p3( imap_store_t *ctx, struct imap_cmd *cmd ATTR_UNUSED, int response ) { - if (response != RESP_OK) + if (response == RESP_NO) imap_open_store_bail( ctx ); - else + else if (response == RESP_OK) imap_open_store_authenticate2( ctx ); } #endif @@ -1453,9 +1453,9 @@ imap_open_store_authenticate2( imap_store_t *ctx ) static void imap_open_store_authenticate2_p2( imap_store_t *ctx, struct imap_cmd *cmd ATTR_UNUSED, int response ) { - if (response != RESP_OK) + if (response == RESP_NO) imap_open_store_bail( ctx ); - else + else if (response == RESP_OK) imap_open_store_namespace( ctx ); } @@ -1480,9 +1480,9 @@ imap_open_store_namespace( imap_store_t *ctx ) static void imap_open_store_namespace_p2( imap_store_t *ctx, struct imap_cmd *cmd ATTR_UNUSED, int response ) { - if (response != RESP_OK) { + if (response == RESP_NO) { imap_open_store_bail( ctx ); - } else { + } else if (response == RESP_OK) { ctx->got_namespace = 1; imap_open_store_namespace2( ctx ); }