]> git.puffer.fish Git - mirror/frr.git/commitdiff
vtysh: Fix, guard against NULL pointer dereference
authorJafar Al-Gharaibeh <jafar@atcorp.com>
Mon, 1 Aug 2016 23:14:38 +0000 (18:14 -0500)
committerDonald Sharp <sharpd@cumulusnetwroks.com>
Sat, 3 Sep 2016 11:29:21 +0000 (07:29 -0400)
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>
vtysh/vtysh_user.c

index 988c768dcefbf3a84345d5b21cf5d0386ca18f41..1886ba3a67b2380f36794a08a67ca30e3207b62d 100644 (file)
@@ -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)