summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2019-01-14 04:05:42 +0000
committerkrw <krw@openbsd.org>2019-01-14 04:05:42 +0000
commita30f5dcbf70f3be348d874527092bd77152776db (patch)
tree0ffa530e80db62a6398cd38ddb987999a5d3e343
parentFix unveil issue noticed by kn@ where unveil does not notice covering (diff)
downloadwireguard-openbsd-a30f5dcbf70f3be348d874527092bd77152776db.tar.xz
wireguard-openbsd-a30f5dcbf70f3be348d874527092bd77152776db.zip
Abstract allocation and initialization of config global
variable into init_config() and just call it from read_conf().
-rw-r--r--sbin/dhclient/clparse.c33
-rw-r--r--sbin/dhclient/dhclient.c6
-rw-r--r--sbin/dhclient/dhcpd.h3
3 files changed, 25 insertions, 17 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 831c5c6c513..ee70cc4ab80 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.174 2019/01/14 03:05:33 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.175 2019/01/14 04:05:42 krw Exp $ */
/* Parser for dhclient config and lease files. */
@@ -76,21 +76,15 @@ void parse_lease_decl(FILE *, struct client_lease *, char *);
int parse_option(FILE *, int *, struct option_data *);
int parse_reject_statement(FILE *);
-/*
- * conf-decls :==
- * <nil>
- * | conf-decl
- * | conf-decls conf-decl
- */
void
-read_conf(char *name)
+init_config(void)
{
struct option_data *option;
- FILE *cfile;
- int token;
uint32_t expiry;
- new_parse(path_dhclient_conf);
+ config = calloc(1, sizeof(*config));
+ if (config == NULL)
+ fatal("config");
TAILQ_INIT(&config->reject_list);
@@ -144,6 +138,23 @@ read_conf(char *name)
[config->requested_option_count++] = DHO_BOOTFILE_NAME;
config->requested_options
[config->requested_option_count++] = DHO_TFTP_SERVER;
+}
+
+/*
+ * conf-decls :==
+ * <nil>
+ * | conf-decl
+ * | conf-decls conf-decl
+ */
+void
+read_conf(char *name)
+{
+ FILE *cfile;
+ int token;
+
+ init_config();
+
+ new_parse(path_dhclient_conf);
if ((cfile = fopen(path_dhclient_conf, "r")) != NULL) {
for (;;) {
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index bb9397e596d..d56dce6a024 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.605 2019/01/14 03:05:33 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.606 2019/01/14 04:05:42 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -574,11 +574,7 @@ main(int argc, char *argv[])
fatal("unpriv_ibuf");
imsg_init(unpriv_ibuf, socket_fd[1]);
- config = calloc(1, sizeof(*config));
- if (config == NULL)
- fatal("config");
read_conf(ifi->name);
-
if ((cmd_opts & OPT_NOACTION) != 0)
return 0;
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 9a71f79dda9..a1af70e9a70 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.266 2019/01/14 03:05:33 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.267 2019/01/14 04:05:42 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -233,6 +233,7 @@ uint32_t checksum(unsigned char *, uint32_t, uint32_t);
uint32_t wrapsum(uint32_t);
/* clparse.c */
+void init_config(void);
void read_conf(char *);
void read_lease_db(char *, struct client_lease_tq *);
void apply_ignore_list(char *);