dovecot: Allow uid/gid names that begin with numbers, as long as...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jul 3 03:55:58 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/5fa84de81413
changeset: 5874:5fa84de81413
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jul 03 03:29:23 2007 +0300
description:
Allow uid/gid names that begin with numbers, as long as it's not completely
a number.

diffstat:

1 file changed, 14 insertions(+), 4 deletions(-)
src/auth/userdb.c |   18 ++++++++++++++----

diffs (43 lines):

diff -r 592a69a21b53 -r 5fa84de81413 src/auth/userdb.c
--- a/src/auth/userdb.c	Tue Jul 03 03:24:46 2007 +0300
+++ b/src/auth/userdb.c	Tue Jul 03 03:29:23 2007 +0300
@@ -49,12 +49,17 @@ uid_t userdb_parse_uid(struct auth_reque
 uid_t userdb_parse_uid(struct auth_request *request, const char *str)
 {
 	struct passwd *pw;
+	uid_t uid;
+	char *p;
 
 	if (str == NULL)
 		return (uid_t)-1;
 
-	if (*str >= '0' && *str <= '9')
-		return (uid_t)strtoul(str, NULL, 10);
+	if (*str >= '0' && *str <= '9') {
+		uid = (uid_t)strtoul(str, &p, 10);
+		if (*p == '\0')
+			return uid;
+	}
 
 	pw = getpwnam(str);
 	if (pw == NULL) {
@@ -70,12 +75,17 @@ gid_t userdb_parse_gid(struct auth_reque
 gid_t userdb_parse_gid(struct auth_request *request, const char *str)
 {
 	struct group *gr;
+	gid_t gid;
+	char *p;
 
 	if (str == NULL)
 		return (gid_t)-1;
 
-	if (*str >= '0' && *str <= '9')
-		return (gid_t)strtoul(str, NULL, 10);
+	if (*str >= '0' && *str <= '9') {
+		gid = (gid_t)strtoul(str, &p, 10);
+		if (*p == '\0')
+			return gid;
+	}
 
 	gr = getgrnam(str);
 	if (gr == NULL) {


More information about the dovecot-cvs mailing list