[dovecot-cvs] dovecot/src/auth md5crypt.c,1.1,1.2 md5crypt.h,1.1,1.2 password-scheme.c,1.2,1.3

cras at procontrol.fi cras at procontrol.fi
Fri Apr 4 03:42:57 EEST 2003


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

Modified Files:
	md5crypt.c md5crypt.h password-scheme.c 
Log Message:
MD5crypt password fixes.



Index: md5crypt.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/md5crypt.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- md5crypt.c	19 Feb 2003 11:28:56 -0000	1.1
+++ md5crypt.c	3 Apr 2003 23:42:54 -0000	1.2
@@ -44,11 +44,11 @@
  * Use MD5 for what it is best at...
  */
 
-char *
+const char *
 md5_crypt(const char *pw, const char *salt)
 {
-	static char     passwd[120], *p;
-	static const char *sp,*ep;
+	char passwd[120], *p;
+	const char *sp,*ep;
 	unsigned char	final[16];
 	int sl,pl,i,j;
 	struct md5_context ctx,ctx1;
@@ -143,5 +143,5 @@
 	/* Don't leave anything around in vm they could use. */
 	memset(final,0,sizeof final);
 
-	return passwd;
+	return t_strdup(passwd);
 }

Index: md5crypt.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/md5crypt.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- md5crypt.h	19 Feb 2003 11:28:56 -0000	1.1
+++ md5crypt.h	3 Apr 2003 23:42:54 -0000	1.2
@@ -1,6 +1,6 @@
 #ifndef __MD5CRYPT_H
 #define __MD5CRYPT_H
 
-char *md5_crypt(const char *pw, const char *salt);
+const char *md5_crypt(const char *pw, const char *salt);
 
 #endif

Index: password-scheme.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/password-scheme.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- password-scheme.c	19 Feb 2003 11:28:56 -0000	1.2
+++ password-scheme.c	3 Apr 2003 23:42:54 -0000	1.3
@@ -59,8 +59,15 @@
 		return NULL;
 
 	if (strncmp(*password, "$1$", 3) == 0) {
-		*password = t_strcut(*password + 3, '$');
-		return "MD5";
+		/* skip the salt */
+		p = strchr(*password + 3, '$');
+		if (p != NULL) {
+			/* stop at next '$' */
+			p = strchr(p+1, '$');
+			if (p != NULL)
+				*password = t_strdup_until(*password, p);
+			return "MD5";
+		}
 	}
 
 	if (**password != '{')




More information about the dovecot-cvs mailing list