[dovecot-cvs] dovecot/src/auth passdb-cache.c,1.17.2.1,1.17.2.2

tss at dovecot.org tss at dovecot.org
Thu Feb 15 10:31:18 UTC 2007


Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv18154

Modified Files:
      Tag: branch_1_0
	passdb-cache.c 
Log Message:
If last login was valid and the current one wasn't, we returned "not found
from cache" but extra_fields still had been modified, which could have
caused crashes later.



Index: passdb-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-cache.c,v
retrieving revision 1.17.2.1
retrieving revision 1.17.2.2
diff -u -d -r1.17.2.1 -r1.17.2.2
--- passdb-cache.c	13 Oct 2006 16:37:10 -0000	1.17.2.1
+++ passdb-cache.c	15 Feb 2007 10:31:16 -0000	1.17.2.2
@@ -13,9 +13,6 @@
 {
 	const char *name, *value;
 
-	if (*list == NULL)
-		return;
-
 	for (; *list != NULL; list++) {
 		t_push();
 		value = strchr(*list, '=');
@@ -57,30 +54,32 @@
 	}
 
 	list = t_strsplit(value, "\t");
-        list_save(request, list + 1);
 
 	cached_pw = list[0];
 	if (*cached_pw == '\0') {
 		/* NULL password */
 		auth_request_log_info(request, "cache", "NULL password access");
-		*result_r = PASSDB_RESULT_OK;
-		return TRUE;
-	}
-
-	scheme = password_get_scheme(&cached_pw);
-	i_assert(scheme != NULL);
+		ret = 1;
+	} else {
+		scheme = password_get_scheme(&cached_pw);
+		i_assert(scheme != NULL);
 
-	ret = auth_request_password_verify(request, password, cached_pw,
-					   scheme, "cache");
+		ret = auth_request_password_verify(request, password, cached_pw,
+						   scheme, "cache");
 
-	if (ret == 0 && node->last_success) {
-		/* the last authentication was successful. assume that the
-		   password was changed and cache is expired. */
-		node->last_success = FALSE;
-		return FALSE;
+		if (ret == 0 && node->last_success) {
+			/* the last authentication was successful. assume that
+			   the password was changed and cache is expired. */
+			node->last_success = FALSE;
+			return FALSE;
+		}
 	}
 	node->last_success = ret > 0;
 
+	/* save the extra_fields only after we know we're using the
+	   cached data */
+	list_save(request, list + 1);
+
 	*result_r = ret > 0 ? PASSDB_RESULT_OK :
 		PASSDB_RESULT_PASSWORD_MISMATCH;
 	return TRUE;



More information about the dovecot-cvs mailing list