Avoid a NULL dereference when getgrnam_r() returns NULL for `result'.
authoryasuoka <yasuoka@openbsd.org>
Mon, 19 Oct 2015 07:58:28 +0000 (07:58 +0000)
committeryasuoka <yasuoka@openbsd.org>
Mon, 19 Oct 2015 07:58:28 +0000 (07:58 +0000)
usr.sbin/radiusd/radiusd_bsdauth.c

index b610a54..c7f8307 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: radiusd_bsdauth.c,v 1.4 2015/07/30 08:46:04 yasuoka Exp $     */
+/*     $OpenBSD: radiusd_bsdauth.c,v 1.5 2015/10/19 07:58:28 yasuoka Exp $     */
 
 /*
  * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@@ -167,7 +167,7 @@ main(int argc, char *argv[])
 
                                pw = getpwnam(user);
                                if (getgrnam_r(group, &gr0, g_buf,
-                                   sizeof(g_buf), &gr) == -1)
+                                   sizeof(g_buf), &gr) == -1 || gr == NULL)
                                        goto group_done;
 
                                if (gr->gr_gid == pw->pw_gid) {