From 492360f4ac483b5d0bff8961d5c7713700b55ab1 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Fri, 30 Oct 2015 00:46:52 +0000 Subject: 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 --- pw/pw_user.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pw') 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); -- cgit v1.2.3-56-ge451