vtysh: Fix, guard against NULL pointer dereference
getpwuid() may fail returning a null value leaving subsequent
code vulnerable to a null pointer dereference.
Tested-by: NetDEF CI System <cisystem@netdef.org>
diff --git a/vtysh/vtysh_user.c b/vtysh/vtysh_user.c
index 248b181..584b61f 100644
--- a/vtysh/vtysh_user.c
+++ b/vtysh/vtysh_user.c
@@ -176,7 +176,11 @@
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)