[dovecot-cvs] dovecot/src/auth mech-cram-md5.c,1.10,1.11

cras at dovecot.org cras at dovecot.org
Wed Sep 29 18:44:40 EEST 2004


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

Modified Files:
	mech-cram-md5.c 
Log Message:
Allow spaces in username.



Index: mech-cram-md5.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-cram-md5.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- mech-cram-md5.c	31 Aug 2004 09:31:18 -0000	1.10
+++ mech-cram-md5.c	29 Sep 2004 15:44:38 -0000	1.11
@@ -86,23 +86,25 @@
 			       const unsigned char *data, size_t size,
 			       const char **error_r)
 {
-	size_t i;
+	size_t i, space;
 
 	*error_r = NULL;
 
-	for (i = 0; i < size; i++) {
+	/* <username> SPACE <response>. Username may contain spaces, so assume
+	   the rightmost space is the response separator. */
+	for (i = space = 0; i < size; i++) {
 		if (data[i] == ' ')
-			break;
+			space = i;
 	}
 
-	if (i == size) {
+	if (space == 0) {
 		*error_r = "missing digest";
 		return FALSE;
 	}
 
-	auth->username = p_strndup(auth->pool, data, i);
-	i++;
-	auth->response = p_strndup(auth->pool, data + i, size - i);
+	auth->username = p_strndup(auth->pool, data, space);
+	space++;
+	auth->response = p_strndup(auth->pool, data + space, size - space);
 	return TRUE;
 }
 



More information about the dovecot-cvs mailing list