From: Todd C. Miller Date: Sun, 25 Nov 2012 14:23:17 +0000 (-0500) Subject: Ignore bad lines in passwd/group file instead if stopping processing when we hit... X-Git-Tag: SUDO_1_8_7~1^2~324 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e81eb5b00af84bba991aaa6ec8e5d48ec95a38db;p=sudo Ignore bad lines in passwd/group file instead if stopping processing when we hit one. --- diff --git a/plugins/sudoers/tsgetgrpw.c b/plugins/sudoers/tsgetgrpw.c index 7b9ad790e..4fd933602 100644 --- a/plugins/sudoers/tsgetgrpw.c +++ b/plugins/sudoers/tsgetgrpw.c @@ -1,5 +1,6 @@ /* - * Copyright (c) 2005, 2008, 2010-2011 Todd C. Miller + * Copyright (c) 2005, 2008, 2010-2012 + * Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -116,32 +117,33 @@ getpwent(void) size_t len; char *cp, *colon; +next_entry: if ((colon = fgets(pwbuf, sizeof(pwbuf), pwf)) == NULL) return NULL; zero_bytes(&pw, sizeof(pw)); if ((colon = strchr(cp = colon, ':')) == NULL) - return NULL; + goto next_entry; *colon++ = '\0'; pw.pw_name = cp; if ((colon = strchr(cp = colon, ':')) == NULL) - return NULL; + goto next_entry; *colon++ = '\0'; pw.pw_passwd = cp; if ((colon = strchr(cp = colon, ':')) == NULL) - return NULL; + goto next_entry; *colon++ = '\0'; pw.pw_uid = atoi(cp); if ((colon = strchr(cp = colon, ':')) == NULL) - return NULL; + goto next_entry; *colon++ = '\0'; pw.pw_gid = atoi(cp); if ((colon = strchr(cp = colon, ':')) == NULL) - return NULL; + goto next_entry; *colon++ = '\0'; pw.pw_gecos = cp; if ((colon = strchr(cp = colon, ':')) == NULL) - return NULL; + goto next_entry; *colon++ = '\0'; pw.pw_dir = cp; pw.pw_shell = colon; @@ -237,20 +239,21 @@ getgrent(void) char *cp, *colon; int n; +next_entry: if ((colon = fgets(grbuf, sizeof(grbuf), grf)) == NULL) return NULL; zero_bytes(&gr, sizeof(gr)); if ((colon = strchr(cp = colon, ':')) == NULL) - return NULL; + goto next_entry; *colon++ = '\0'; gr.gr_name = cp; if ((colon = strchr(cp = colon, ':')) == NULL) - return NULL; + goto next_entry; *colon++ = '\0'; gr.gr_passwd = cp; if ((colon = strchr(cp = colon, ':')) == NULL) - return NULL; + goto next_entry; *colon++ = '\0'; gr.gr_gid = atoi(cp); len = strlen(colon);