summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2015-02-12 23:07:53 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2015-02-12 23:07:53 +0000
commit74f1abc60252004975fc7ed4a64077ab35f64f3b (patch)
treef7f36aa3bd6e656f0dd07ebcfb310b355e984397 /usr.sbin
parent734e3422b53671b765e8eb8423430ff2983db764 (diff)
Allow constraints URL without leading path (eg. "https://www.openbsd.org").
Fixes segfault on configuration load time, as reported by Donovan Watteau.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ntpd/parse.y17
1 files changed, 9 insertions, 8 deletions
diff --git a/usr.sbin/ntpd/parse.y b/usr.sbin/ntpd/parse.y
index e5b403b4f72..ba3d592a29e 100644
--- a/usr.sbin/ntpd/parse.y
+++ b/usr.sbin/ntpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.60 2015/02/12 01:54:57 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.61 2015/02/12 23:07:52 reyk Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -316,21 +316,22 @@ url : STRING {
strlen("https://")) != 0) {
host($1, &$$->a);
$$->name = $1;
- if (($$->path = strdup("/")) == NULL)
- fatal("strdup");
} else {
hname = $1 + strlen("https://");
path = hname + strcspn(hname, "/\\");
- if (*path == '\0')
- path = "/";
- if (($$->path = strdup(path)) == NULL)
- fatal("strdup");
- *path = '\0';
+ if (*path != '\0') {
+ if (($$->path = strdup(path)) == NULL)
+ fatal("strdup");
+ *path = '\0';
+ }
host(hname, &$$->a);
if (($$->name = strdup(hname)) == NULL)
fatal("strdup");
}
+ if ($$->path == NULL &&
+ ($$->path = strdup("/")) == NULL)
+ fatal("strdup");
}
;