From 6cac0d1ff5f7d6b4ab63ccf681602439e8b0068a Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 9 Sep 2004 20:51:58 +0000 Subject: Avoid following a NULL pointer if a hostname lookup fails and remove an extraneous "exiting" when there is a config file error. OK henning@ and mcbride@ --- usr.sbin/dhcpd/confpars.c | 6 ++++-- usr.sbin/dhcpd/dhcpd.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.sbin/dhcpd/confpars.c b/usr.sbin/dhcpd/confpars.c index a2c87cf0403..72d5ef48b68 100644 --- a/usr.sbin/dhcpd/confpars.c +++ b/usr.sbin/dhcpd/confpars.c @@ -1,4 +1,4 @@ -/* $OpenBSD: confpars.c,v 1.9 2004/05/08 06:11:53 henning Exp $ */ +/* $OpenBSD: confpars.c,v 1.10 2004/09/09 20:51:57 millert Exp $ */ /* * Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. @@ -831,9 +831,11 @@ struct tree *parse_ip_addr_or_hostname(cfile, uniform) if (!name) return NULL; h = gethostbyname(name); - if (h == NULL) + if (h == NULL) { parse_warn("%s (%d): could not resolve hostname", val, token); + return NULL; + } rv = tree_const(h->h_addr_list[0], h->h_length); if (!uniform) rv = tree_limit(rv, 4); diff --git a/usr.sbin/dhcpd/dhcpd.c b/usr.sbin/dhcpd/dhcpd.c index 39aa1f4472c..cea9db57771 100644 --- a/usr.sbin/dhcpd/dhcpd.c +++ b/usr.sbin/dhcpd/dhcpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.c,v 1.19 2004/05/12 10:20:49 henning Exp $ */ +/* $OpenBSD: dhcpd.c,v 1.20 2004/09/09 20:51:57 millert Exp $ */ /* * Copyright (c) 2004 Henning Brauer @@ -120,7 +120,7 @@ main(int argc, char *argv[]) time(&cur_time); if (!readconf()) - error("Configuration file errors encountered -- exiting"); + error("Configuration file errors encountered"); if (cftest) exit(0); -- cgit v1.2.3