dovecot-2.0: auth: Make sure userdb iteration doesn't free memor...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jul 19 19:38:00 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/f178792fb820
changeset: 11859:f178792fb820
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jul 19 17:37:55 2010 +0100
description:
auth: Make sure userdb iteration doesn't free memory too early if it's aborted.

diffstat:

 src/auth/userdb-blocking.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (38 lines):

diff -r e6f376a1c755 -r f178792fb820 src/auth/userdb-blocking.c
--- a/src/auth/userdb-blocking.c	Mon Jul 19 15:42:22 2010 +0100
+++ b/src/auth/userdb-blocking.c	Mon Jul 19 17:37:55 2010 +0100
@@ -65,19 +65,19 @@
 static bool iter_callback(const char *reply, void *context)
 {
 	struct blocking_userdb_iterate_context *ctx = context;
+	pool_t pool = ctx->pool;
 
 	if (strncmp(reply, "*\t", 2) == 0) {
 		ctx->next = FALSE;
 		ctx->ctx.callback(reply + 2, ctx->ctx.context);
 		return ctx->next;
-	} else if (strcmp(reply, "OK") == 0) {
-		ctx->ctx.callback(NULL, ctx->ctx.context);
-		return TRUE;
-	} else {
+	}
+
+	if (strcmp(reply, "OK") != 0)
 		ctx->ctx.failed = TRUE;
-		ctx->ctx.callback(NULL, ctx->ctx.context);
-		return TRUE;
-	}
+	ctx->ctx.callback(NULL, ctx->ctx.context);
+	pool_unref(&pool);
+	return TRUE;
 }
 
 struct userdb_iterate_context *
@@ -99,6 +99,7 @@
 	ctx->ctx.context = context;
 	ctx->pool = pool;
 
+	pool_ref(pool);
 	ctx->conn = auth_worker_call(pool, reply, iter_callback, ctx);
 	return &ctx->ctx;
 }


More information about the dovecot-cvs mailing list