diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2019-10-18 17:15:46 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2019-10-18 17:15:46 +0000 |
commit | 261e8c3fe99846e64de96154af5f26b85b3f744a (patch) | |
tree | 1a9b94ea054172c258e3b24f1be55dd9ebfd6ce2 /usr.bin/doas/doas.c | |
parent | f03a695d23c61cb5cbb5c4dfa6875be2ab194f9e (diff) |
add some checks to avoid UID_MAX (-1) here. this is not problematic with
the current code, but it's probably safer this way.
ok deraadt
Diffstat (limited to 'usr.bin/doas/doas.c')
-rw-r--r-- | usr.bin/doas/doas.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/doas/doas.c b/usr.bin/doas/doas.c index dfd8c8603bf..a723c67a3eb 100644 --- a/usr.bin/doas/doas.c +++ b/usr.bin/doas/doas.c @@ -1,4 +1,4 @@ -/* $OpenBSD: doas.c,v 1.81 2019/09/14 17:47:00 semarie Exp $ */ +/* $OpenBSD: doas.c,v 1.82 2019/10/18 17:15:45 tedu Exp $ */ /* * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org> * @@ -52,9 +52,11 @@ parseuid(const char *s, uid_t *uid) if ((pw = getpwnam(s)) != NULL) { *uid = pw->pw_uid; + if (*uid == UID_MAX) + return -1; return 0; } - *uid = strtonum(s, 0, UID_MAX, &errstr); + *uid = strtonum(s, 0, UID_MAX - 1, &errstr); if (errstr) return -1; return 0; @@ -80,9 +82,11 @@ parsegid(const char *s, gid_t *gid) if ((gr = getgrnam(s)) != NULL) { *gid = gr->gr_gid; + if (*gid == GID_MAX) + return -1; return 0; } - *gid = strtonum(s, 0, GID_MAX, &errstr); + *gid = strtonum(s, 0, GID_MAX - 1, &errstr); if (errstr) return -1; return 0; |