Blame SOURCES/sudo-1.8.6p3-strictuidgid.patch

1b092f
diff -up sudo-1.8.6p3/plugins/sudoers/match.c.strictuidgid sudo-1.8.6p3/plugins/sudoers/match.c
1b092f
--- sudo-1.8.6p3/plugins/sudoers/match.c.strictuidgid	2012-09-18 15:56:29.000000000 +0200
1b092f
+++ sudo-1.8.6p3/plugins/sudoers/match.c	2013-08-08 16:22:00.413281960 +0200
1b092f
@@ -650,14 +650,16 @@ hostname_matches(char *shost, char *lhos
1b092f
 bool
1b092f
 userpw_matches(char *sudoers_user, char *user, struct passwd *pw)
1b092f
 {
1b092f
-    debug_decl(userpw_matches, SUDO_DEBUG_MATCH)
1b092f
-
1b092f
-    if (pw != NULL && *sudoers_user == '#') {
1b092f
-	uid_t uid = (uid_t) atoi(sudoers_user + 1);
1b092f
-	if (uid == pw->pw_uid)
1b092f
-	    debug_return_bool(true);
1b092f
-    }
1b092f
-    debug_return_bool(strcmp(sudoers_user, user) == 0);
1b092f
+	debug_decl(userpw_matches, SUDO_DEBUG_MATCH)
1b092f
+	if (pw != NULL && *sudoers_user == '#') {
1b092f
+		char *end = NULL;
1b092f
+		uid_t uid = (uid_t) strtol(sudoers_user + 1, &end, 10);
1b092f
+		if (end != NULL && (sudoers_user[1] != '\0' && *end == '\0')) {
1b092f
+			if (uid == pw->pw_uid)
1b092f
+				debug_return_bool(true);
1b092f
+		}
1b092f
+	}
1b092f
+	debug_return_bool(strcmp(sudoers_user, user) == 0);
1b092f
 }
1b092f
 
1b092f
 /*
1b092f
@@ -667,14 +669,16 @@ userpw_matches(char *sudoers_user, char
1b092f
 bool
1b092f
 group_matches(char *sudoers_group, struct group *gr)
1b092f
 {
1b092f
-    debug_decl(group_matches, SUDO_DEBUG_MATCH)
1b092f
-
1b092f
-    if (*sudoers_group == '#') {
1b092f
-	gid_t gid = (gid_t) atoi(sudoers_group + 1);
1b092f
-	if (gid == gr->gr_gid)
1b092f
-	    debug_return_bool(true);
1b092f
-    }
1b092f
-    debug_return_bool(strcmp(gr->gr_name, sudoers_group) == 0);
1b092f
+	debug_decl(group_matches, SUDO_DEBUG_MATCH)
1b092f
+	if (*sudoers_group == '#') {
1b092f
+		char *end = NULL;
1b092f
+		gid_t gid = (gid_t) strtol(sudoers_group + 1, &end, 10);
1b092f
+		if (end != NULL && (sudoers_group[1] != '\0' && *end == '\0')) {
1b092f
+			if (gid == gr->gr_gid)
1b092f
+				debug_return_bool(true);
1b092f
+		}
1b092f
+	}
1b092f
+	debug_return_bool(strcmp(gr->gr_name, sudoers_group) == 0);
1b092f
 }
1b092f
 
1b092f
 /*