From c3ddb2dd14bd7a39dedbbf3520c9a2052dd3e1ff Mon Sep 17 00:00:00 2001 From: Josuah Demangeon Date: Mon, 2 Apr 2018 02:55:00 +0200 Subject: [PATCH] permit prefix to be empty in -v format string The previous parsing of the -v vhosts made sure there were 4 tokens. If there was no prefix specified, usage() is called. Now, it only checks for the firsts 3, with .prefix set to null if there are only 3 tokens. --- main.c | 8 +++++--- quark.1 | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 5f1c6d9..943d146 100644 --- a/main.c +++ b/main.c @@ -172,9 +172,11 @@ main(int argc, char *argv[]) } if (!(s.vhost[s.vhost_len - 1].chost = strtok(tok, " ")) || !(s.vhost[s.vhost_len - 1].regex = strtok(NULL, " ")) || - !(s.vhost[s.vhost_len - 1].dir = strtok(NULL, " ")) || - !(s.vhost[s.vhost_len - 1].prefix = strtok(NULL, " ")) || - strtok(NULL, "")) { + !(s.vhost[s.vhost_len - 1].dir = strtok(NULL, " "))) { + usage(); + } + s.vhost[s.vhost_len - 1].prefix = strtok(NULL, " "); + if (strtok(NULL, "")) { usage(); } break; diff --git a/quark.1 b/quark.1 index 7179a86..2d48842 100644 --- a/quark.1 +++ b/quark.1 @@ -96,7 +96,7 @@ The default is "nobody". Add the virtual host specified by .Ar vhost , which has the form -.Qq Pa chost regex dir prefix , +.Qq Pa chost regex dir [prefix] , where each element is separated with whitespace. .Pp A request matching the virtual host regular expression