[dovecot-cvs] dovecot/src/auth auth-plain.c,1.11,1.12

cras at procontrol.fi cras at procontrol.fi
Mon Jan 20 15:53:33 EET 2003


Update of /home/cvs/dovecot/src/auth
In directory danu:/tmp/cvs-serv8718/auth

Modified Files:
	auth-plain.c 
Log Message:
PLAIN SASL-authentication was a bit broken.



Index: auth-plain.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/auth-plain.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- auth-plain.c	11 Jan 2003 19:55:56 -0000	1.11
+++ auth-plain.c	20 Jan 2003 13:53:31 -0000	1.12
@@ -13,7 +13,7 @@
 {
 	struct auth_cookie_reply_data *cookie_reply = cookie->context;
 	struct auth_reply_data reply;
-	const char *user;
+	const char *authid, *authenid;
 	char *pass;
 	size_t i, count, len;
 
@@ -23,27 +23,29 @@
 	reply.result = AUTH_RESULT_FAILURE;
 	memcpy(reply.cookie, cookie->cookie, AUTH_COOKIE_SIZE);
 
-	/* data should contain user\0...\0pass */
-	user = (const char *) data;
-	pass = NULL;
+	/* authorization ID \0 authentication ID \0 pass.
+	   we'll ignore authorization ID for now. */
+	authid = (const char *) data;
+	authenid = NULL; pass = NULL;
+
 	count = 0;
 	for (i = 0; i < request->data_size; i++) {
-		if (data[i] == '\0' && ++count == 2) {
-			i++;
-			if (i == request->data_size)
-				pass = "";
+		if (data[i] == '\0') {
+			if (++count == 1)
+				authenid = data + i+1;
 			else {
+				i++;
 				len = request->data_size - i;
 				pass = t_malloc(len+1);
-                                memcpy(pass, (const char *) data + i, len);
-                                pass[len] = '\0';
+				memcpy(pass, data + i, len);
+				pass[len] = '\0';
+				break;
 			}
-			break;
 		}
 	}
 
 	if (pass != NULL) {
-		if (userinfo->verify_plain(user, pass, cookie_reply)) {
+		if (userinfo->verify_plain(authenid, pass, cookie_reply)) {
 			cookie_reply->success = TRUE;
 			reply.result = AUTH_RESULT_SUCCESS;
 




More information about the dovecot-cvs mailing list