Browse Source

Allow constraints URL without leading path (eg. "https://www.openbsd.org").

Fixes segfault on configuration load time, as reported by Donovan Watteau.
OPENBSD_5_7
reyk 9 years ago
parent
commit
57c6dae142
1 changed files with 9 additions and 8 deletions
  1. +9
    -8
      src/usr.sbin/ntpd/parse.y

+ 9
- 8
src/usr.sbin/ntpd/parse.y View File

@ -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> * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -316,21 +316,22 @@ url : STRING {
strlen("https://")) != 0) { strlen("https://")) != 0) {
host($1, &$$->a); host($1, &$$->a);
$$->name = $1; $$->name = $1;
if (($$->path = strdup("/")) == NULL)
fatal("strdup");
} else { } else {
hname = $1 + strlen("https://"); hname = $1 + strlen("https://");
path = hname + strcspn(hname, "/\\"); 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); host(hname, &$$->a);
if (($$->name = strdup(hname)) == NULL) if (($$->name = strdup(hname)) == NULL)
fatal("strdup"); fatal("strdup");
} }
if ($$->path == NULL &&
($$->path = strdup("/")) == NULL)
fatal("strdup");
} }
; ;


Loading…
Cancel
Save