# HG changeset patch # User Jim Meyering # Date 1259389996 -3600 # Node ID 3cbb46b89edfe68304250bc2286afa33ffacc1c2 # Parent d3dfa66dec267a96251a147941ad66c2802fd92d userspec: disallow an ID that maps to (uid_t)-1 or (gid_t)-1 * lib/userspec.c (parse_with_separator): Do not accept a user ID number of MAXUID when it evaluates to (uid_t) -1. Likewise for group ID. Reported by Matt McCutchen in diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-11-28 Jim Meyering + userspec: disallow an ID that maps to (uid_t)-1 or (gid_t)-1 + * lib/userspec.c (parse_with_separator): Do not accept a user ID + number of MAXUID when it evaluates to (uid_t) -1. + Likewise for group ID. Reported by Matt McCutchen in + + userspec: reformat to use spaces, not TABs * lib/userspec.c: Expand TABs to spaces. Add Emacs' "indent-tabs-mode: nil" hint. diff --git a/lib/userspec.c b/lib/userspec.c --- a/lib/userspec.c +++ b/lib/userspec.c @@ -169,7 +169,7 @@ { unsigned long int tmp; if (xstrtoul (u, NULL, 10, &tmp, "") == LONGINT_OK - && tmp <= MAXUID) + && tmp <= MAXUID && (uid_t) tmp != (uid_t) -1) unum = tmp; else error_msg = E_invalid_user; @@ -200,7 +200,8 @@ if (grp == NULL) { unsigned long int tmp; - if (xstrtoul (g, NULL, 10, &tmp, "") == LONGINT_OK && tmp <= MAXGID) + if (xstrtoul (g, NULL, 10, &tmp, "") == LONGINT_OK + && tmp <= MAXGID && (gid_t) tmp != (gid_t) -1) gnum = tmp; else error_msg = E_invalid_group;