From: tb Date: Mon, 27 Nov 2023 18:37:53 +0000 (+0000) Subject: Add missing error check for yp_get_default_domain() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c0ddac47be830fbe7b12fe0dfa698e93374edd3b;p=openbsd Add missing error check for yp_get_default_domain() Avoids a crash when no default domain is set. from hshoexer ok deraadt who had the same diff --- diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c index 6a1c5d91fcc..6193961f0b7 100644 --- a/usr.sbin/ypbind/ypbind.c +++ b/usr.sbin/ypbind/ypbind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypbind.c,v 1.78 2023/03/08 04:43:15 guenther Exp $ */ +/* $OpenBSD: ypbind.c,v 1.79 2023/11/27 18:37:53 tb Exp $ */ /* * Copyright (c) 1992, 1993, 1996, 1997, 1998 Theo de Raadt @@ -341,8 +341,7 @@ main(int argc, char *argv[]) DIR *dirp; struct dirent *dent; - yp_get_default_domain(&domain); - if (domain[0] == '\0') { + if (yp_get_default_domain(&domain) != 0 || domain[0] == '\0') { fprintf(stderr, "domainname not set. Aborting.\n"); exit(1); }