From: Jafar Al-Gharaibeh Date: Mon, 1 Aug 2016 23:14:38 +0000 (-0500) Subject: vtysh: Fix, guard against NULL pointer dereference X-Git-Tag: frr-2.0-rc1~352 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=6d128e1d7889924ec6ef5eb897d0ba94fed313db;p=matthieu%2Ffrr.git 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 Signed-off-by: Jafar Al-Gharaibeh Tested-by: NetDEF CI System --- 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)