From fd773ca3ddf2bd9023700efd43252b6c1bfdaa3f Mon Sep 17 00:00:00 2001 From: Eitan Adler Date: Thu, 15 Nov 2012 15:06:18 +0000 Subject: [PATCH] Avoid possible null deref if ypclnt_new returns null PR: bin/172979 Submitted by: Erik Cederstrand Approved by: cperciva MFC after: 3 days --- usr.bin/chpass/chpass.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c index 2504e68ec17d..9f9be5335a68 100644 --- a/usr.bin/chpass/chpass.c +++ b/usr.bin/chpass/chpass.c @@ -241,8 +241,11 @@ main(int argc, char *argv[]) #ifdef YP case _PWF_NIS: ypclnt = ypclnt_new(yp_domain, "passwd.byname", yp_host); - if (ypclnt == NULL || - ypclnt_connect(ypclnt) == -1 || + if (ypclnt == NULL) { + warnx("ypclnt_new failed"); + exit(1); + } + if (ypclnt_connect(ypclnt) == -1 || ypclnt_passwd(ypclnt, pw, password) == -1) { warnx("%s", ypclnt->error); ypclnt_free(ypclnt);