1
0
mirror of https://github.com/openbsd/src.git synced 2026-04-27 15:46:02 +00:00

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
This commit is contained in:
tedu
2019-10-18 17:15:45 +00:00
parent 1917016a80
commit 754f2b84d7

View File

@@ -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;