From 735336b21edbca50b1650df091ed2dad47f96c27 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Mon, 19 Jul 2021 11:15:44 +0000 Subject: [PATCH] unbreak configless mode An un-initialized field in the configless code path leads to a crash on the first request. --- ChangeLog | 4 ++++ gmid.c | 1 + regress/runtime | 21 +++++++++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7fce52..9014989 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2021-07-19 Omar Polo + + * gmid.c (setup_configless): unbreak configless mode + 2021-07-13 Anna “CyberTailor” * parse.y (yyerror): error and warning messages are prefixed with "error:" and "warning:" diff --git a/gmid.c b/gmid.c index 5d6e1cc..01a1684 100644 --- a/gmid.c +++ b/gmid.c @@ -524,6 +524,7 @@ setup_configless(int argc, char **argv, const char *cgi) TAILQ_INSERT_HEAD(&hosts, host, vhosts); loc = xcalloc(1, sizeof(*loc)); + loc->fcgi = -1; TAILQ_INSERT_HEAD(&host->locations, loc, locations); serve(argc, argv, NULL); diff --git a/regress/runtime b/regress/runtime index 32ab472..f156d6a 100755 --- a/regress/runtime +++ b/regress/runtime @@ -13,10 +13,12 @@ fi ggflags= -config_common=' +port=10965 + +config_common=" ipv6 off -port 10965 -' +port $port +" # usage: config # generates a configuration file reg.conf @@ -101,7 +103,18 @@ onexit() { quit } -# tests +# configless tests + +./../gmid -p $port testdata & +pid=$! +sleep 1 + +eq "$(head /)" "20 text/gemini" "Unexpected head for /" +eq "$(get /)" "# hello world$ln" "Unexpected body for /" +echo OK GET / in configless mode +quit + +# daemon tests trap 'onexit' INT TERM EXIT