changeset 20741:806511128f8c

doveadm-auth: Handle unexpected auth "continue" request without crashing.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sat, 10 Sep 2016 11:32:28 +0300
parents 96915258dd31
children ff4c5d5ee76f
files src/doveadm/doveadm-auth.c
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/doveadm-auth.c	Sat Sep 10 11:28:38 2016 +0300
+++ b/src/doveadm/doveadm-auth.c	Sat Sep 10 11:32:28 2016 +0300
@@ -131,14 +131,24 @@
 	if (status == 0)
 		i_fatal("passdb expects SASL continuation");
 
-	if (status < 0)
+	switch (status) {
+	case AUTH_REQUEST_STATUS_ABORT:
+		i_unreached();
+	case AUTH_REQUEST_STATUS_INTERNAL_FAIL:
+	case AUTH_REQUEST_STATUS_FAIL:
 		printf("passdb: %s auth failed\n", input->username);
-	else {
+		break;
+	case AUTH_REQUEST_STATUS_CONTINUE:
+		printf("passdb: %s auth unexpectedly requested continuation\n",
+		       input->username);
+		break;
+	case AUTH_REQUEST_STATUS_OK:
 		input->success = TRUE;
 		printf("passdb: %s auth succeeded\n", input->username);
+		break;
 	}
 
-	if (*args != NULL) {
+	if (args != NULL && *args != NULL) {
 		printf("extra fields:\n");
 		for (; *args != NULL; args++)
 			printf("  %s\n", *args);