summaryrefslogtreecommitdiffstats
path: root/pw
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2015-10-30 00:46:52 +0000
committerXin LI <delphij@FreeBSD.org>2015-10-30 00:46:52 +0000
commit53d5541556909952101aae809c6d30717ab497d0 (patch)
treefc17b7c986abe5d246e9e37449bdc66551b675c2 /pw
parentd7268f1e76677b28d0ebecae94276c34bc8cba54 (diff)
downloadpw-darwin-53d5541556909952101aae809c6d30717ab497d0.tar.gz
pw-darwin-53d5541556909952101aae809c6d30717ab497d0.tar.zst
pw-darwin-53d5541556909952101aae809c6d30717ab497d0.zip
In pw_userlock, set 'name' to NULL when we encounter an all number string
because it is also used as an indicator of whether a name or an UID is being used and we may have undefined results as 'name' may contain uninitialized stack contents. MFC after: 2 weeks
Diffstat (limited to 'pw')
-rw-r--r--pw/pw_user.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c
index 345f642..5c168ab 100644
--- a/pw/pw_user.c
+++ b/pw/pw_user.c
@@ -282,9 +282,10 @@ pw_userlock(char *arg1, int mode)
if (arg1 == NULL)
errx(EX_DATAERR, "username or id required");
- if (arg1[strspn(arg1, "0123456789")] == '\0')
+ if (arg1[strspn(arg1, "0123456789")] == '\0') {
id = pw_checkid(arg1, UID_MAX);
- else
+ name = NULL;
+ } else
name = arg1;
pwd = (name != NULL) ? GETPWNAM(pw_checkname(name, 0)) : GETPWUID(id);