Jelajahi Sumber

fix crashes in imap_open_store() error paths

it's not a good idea to invoke imap_open_store_bail() twice, either ...
Oswald Buddenhagen 12 tahun lalu
induk
melakukan
3363ad0f11
1 mengubah file dengan 10 tambahan dan 10 penghapusan
  1. 10 10
      src/drv_imap.c

+ 10 - 10
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 );
 	}