summaryrefslogtreecommitdiff
path: root/vtysh/vtysh_user.c
diff options
context:
space:
mode:
authorJafar Al-Gharaibeh <jafar@atcorp.com>2016-08-01 18:14:38 -0500
committerDonald Sharp <sharpd@cumulusnetwroks.com>2016-09-03 07:29:21 -0400
commit6d128e1d7889924ec6ef5eb897d0ba94fed313db (patch)
treee6539bbcb6b6f017949e3e476d8dae614fcea1aa /vtysh/vtysh_user.c
parentbfe15094c260719095c92ecc617ad29fdda160eb (diff)
vtysh: Fix, guard against NULL pointer dereference
getpwuid() may fail returning a null value leaving subsequent code vulnerable to a null pointer dereference. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com> Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com> Tested-by: NetDEF CI System <cisystem@netdef.org>
Diffstat (limited to 'vtysh/vtysh_user.c')
-rw-r--r--vtysh/vtysh_user.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/vtysh/vtysh_user.c b/vtysh/vtysh_user.c
index 988c768dce..1886ba3a67 100644
--- a/vtysh/vtysh_user.c
+++ b/vtysh/vtysh_user.c
@@ -195,7 +195,11 @@ vtysh_auth (void)
struct vtysh_user *user;
struct passwd *passwd;
- passwd = getpwuid (geteuid ());
+ if ((passwd = getpwuid (geteuid ())) == NULL)
+ {
+ fprintf (stderr, "could not lookup user ID %d\n", (int) geteuid());
+ exit (1);
+ }
user = user_lookup (passwd->pw_name);
if (user && user->nopassword)