ngompa / rpms / sudo

Forked from rpms/sudo 2 years ago
Clone
8729726
diff -up sudo-1.8.8/plugins/sudoers/match.c.strictuidgid sudo-1.8.8/plugins/sudoers/match.c
8729726
--- sudo-1.8.8/plugins/sudoers/match.c.strictuidgid	2013-09-30 23:30:12.359263967 +0200
8729726
+++ sudo-1.8.8/plugins/sudoers/match.c	2013-09-30 23:31:04.335443002 +0200
8729726
@@ -777,14 +777,16 @@ hostname_matches(char *shost, char *lhos
8729726
 bool
8729726
 userpw_matches(char *sudoers_user, char *user, struct passwd *pw)
8729726
 {
8729726
-    debug_decl(userpw_matches, SUDO_DEBUG_MATCH)
8729726
-
8729726
-    if (pw != NULL && *sudoers_user == '#') {
8729726
-	uid_t uid = (uid_t) atoi(sudoers_user + 1);
8729726
-	if (uid == pw->pw_uid)
8729726
-	    debug_return_bool(true);
8729726
-    }
8729726
-    debug_return_bool(strcmp(sudoers_user, user) == 0);
8729726
+	debug_decl(userpw_matches, SUDO_DEBUG_MATCH)
8729726
+	if (pw != NULL && *sudoers_user == '#') {
8729726
+		char *end = NULL;
8729726
+		uid_t uid = (uid_t) strtol(sudoers_user + 1, &end, 10);
8729726
+		if (end != NULL && (sudoers_user[1] != '\0' && *end == '\0')) {
8729726
+			if (uid == pw->pw_uid)
8729726
+				debug_return_bool(true);
8729726
+		}
8729726
+	}
8729726
+	debug_return_bool(strcmp(sudoers_user, user) == 0);
8729726
 }
8729726
 
8729726
 /*
8729726
@@ -794,14 +796,16 @@ userpw_matches(char *sudoers_user, char
8729726
 bool
8729726
 group_matches(char *sudoers_group, struct group *gr)
8729726
 {
8729726
-    debug_decl(group_matches, SUDO_DEBUG_MATCH)
8729726
-
8729726
-    if (*sudoers_group == '#') {
8729726
-	gid_t gid = (gid_t) atoi(sudoers_group + 1);
8729726
-	if (gid == gr->gr_gid)
8729726
-	    debug_return_bool(true);
8729726
-    }
8729726
-    debug_return_bool(strcmp(gr->gr_name, sudoers_group) == 0);
8729726
+	debug_decl(group_matches, SUDO_DEBUG_MATCH)
8729726
+	if (*sudoers_group == '#') {
8729726
+		char *end = NULL;
8729726
+		gid_t gid = (gid_t) strtol(sudoers_group + 1, &end, 10);
8729726
+		if (end != NULL && (sudoers_group[1] != '\0' && *end == '\0')) {
8729726
+			if (gid == gr->gr_gid)
8729726
+				debug_return_bool(true);
8729726
+		}
8729726
+	}
8729726
+	debug_return_bool(strcmp(gr->gr_name, sudoers_group) == 0);
8729726
 }
8729726
 
8729726
 /*