Browse Source

Sigh... I wasn't checking if the gid field in a group line actually
contained a digit. Also adjust a comment.

Manuel Novoa III 21 years ago
parent
commit
d5465499fb
1 changed files with 5 additions and 3 deletions
  1. 5 3
      libc/pwd_grp/pwd_grp.c

+ 5 - 3
libc/pwd_grp/pwd_grp.c

@@ -966,7 +966,11 @@ int __parsegrent(void *data, char *line)
 			/* NOTE: glibc difference - glibc allows omission of the
 			 * trailing colon when there is no member list.  We treat
 			 * this as an error. */
-			if (*endptr != ':') {
+
+			/* Make sure we had at least one digit, and that the
+			 * failing char is the next field seperator ':'.  See
+			 * glibc difference note above. */
+			if ((endptr == line) || (*endptr != ':')) {
 				break;
 			}
 
@@ -1104,8 +1108,6 @@ int __parsespent(void *data, char * line)
  * and for which the parser function succeeds.
  *
  * Returns 0 on success and ENOENT for end-of-file (glibc concession).
- * On error, it both sets errno to ERANGE and returns ERANGE.
- * (seems to be glibc behavior.)
  */
 
 int __pgsreader(int (*__parserfunc)(void *d, char *line), void *data,