opendoas

my fork of doas with custom prompt
git clone git://git.kocotian.pl/opendoas.git
Log | Files | Refs | README | LICENSE

commit 3dac6fb553b199cf799e5f5ff6172b97794d22d1
parent 96d78078f6fcddc07b57aa8edabf305e4c12ed68
Author: tedu <tedu>
Date:   Fri, 18 Oct 2019 17:15:45 +0000

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:
Mdoas.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/doas.c b/doas.c @@ -57,9 +57,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; @@ -85,9 +87,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;