commit 2752a87e6f5d95b71b796189e41418098b399a75131a757d1ae4fa7cd1b43f6a from: Stefan Sperling date: Mon Jan 26 14:39:49 2026 UTC ensure that gotwebd.conf parsing errors are actually treated as fatal errors Stop processing the configuration as soon as a fatal error is encountered. Should fix situations where gotwebd would sometimes print multiple unrelated errors, which could be quite confusing. commit - 7857f54b412eee1b52901d868f8567724b661485c2f4212422ddec6af4959f87 commit + 2752a87e6f5d95b71b796189e41418098b399a75131a757d1ae4fa7cd1b43f6a blob - d4e5e5d00208601581bd17a1e2f0c9ca3ea3268f33bf537998d003af6fcaf48b blob + a18b601e76dc2fa0b895bd887b2b11448196cfb25b599573bc9fcdf12bf00f26 --- gotwebd/parse.y +++ gotwebd/parse.y @@ -1515,6 +1515,9 @@ parse_config(const char *filename, struct gotwebd *env ; } + if (errors) + return -1; + /* Free macros and check which have not been used. */ TAILQ_FOREACH_SAFE(sym, &symhead, entry, next) { if ((gotwebd->gotwebd_verbose > 1) && !sym->used) @@ -1602,8 +1605,7 @@ parse_config(const char *filename, struct gotwebd *env if (media_add(&gotwebd->mediatypes, &defaults[i]) == NULL) { fprintf(stderr, "failed to load default" " MIME types\n"); - errors++; - break; + return -1; } } } @@ -1615,24 +1617,24 @@ parse_config(const char *filename, struct gotwebd *env if (strlcpy(path, gotwebd->httpd_chroot, sizeof(path)) >= sizeof(path)) { - yyerror("chroot path too long: %s", + fprintf(stderr, "chroot path too long: %s", gotwebd->httpd_chroot); + return -1; } if (strlcat(path, D_UNIX_SOCKET, sizeof(path)) >= sizeof(path)) { - yyerror("chroot path too long: %s", + fprintf(stderr, "chroot path too long: %s", gotwebd->httpd_chroot); + return -1; } h = get_unix_addr(path); - if (h == NULL) - yyerror("can't listen on %s", path); - else + if (h == NULL) { + fprintf(stderr, "can't listen on %s", path); + return -1; + } else add_addr(h); } - if (errors) { - return (-1); - } /* setup our listening sockets */ sockets_parse_sockets(env); @@ -1693,9 +1695,10 @@ parse_config(const char *filename, struct gotwebd *env if (strlcpy(srv->login_hint_user, env->login_hint_user, sizeof(srv->login_hint_user)) >= sizeof(srv->login_hint_user)) { - yyerror("login hint user name too long, " - "exceeds %zd bytes", + fprintf(stderr, "login hint user name too " + "long, exceeds %zd bytes", sizeof(srv->login_hint_user) - 1); + return -1; } } @@ -1703,9 +1706,10 @@ parse_config(const char *filename, struct gotwebd *env if (strlcpy(srv->login_hint_port, env->login_hint_port, sizeof(srv->login_hint_port)) >= sizeof(srv->login_hint_port)) { - yyerror("login hint port number too long, " - "exceeds %zd bytes", + fprintf(stderr, "login hint port number too " + "long, exceeds %zd bytes", sizeof(srv->login_hint_port) - 1); + return -1; } } @@ -1714,9 +1718,10 @@ parse_config(const char *filename, struct gotwebd *env env->gotweb_url_root, sizeof(srv->gotweb_url_root)) >= sizeof(srv->gotweb_url_root)) { - yyerror("gotweb_url_root too long, " + fprintf(stderr, "gotweb_url_root too long, " "exceeds %zd bytes", sizeof(srv->gotweb_url_root) - 1); + return -1; } } @@ -1725,9 +1730,10 @@ parse_config(const char *filename, struct gotwebd *env env->repos_url_path, sizeof(srv->repos_url_path)) >= sizeof(srv->repos_url_path)) { - yyerror("repos_url_path too long, " + fprintf(stderr, "repos_url_path too long, " "exceeds %zd bytes", sizeof(srv->repos_url_path) - 1); + return -1; } } } @@ -1753,13 +1759,13 @@ parse_config(const char *filename, struct gotwebd *env "/%s%s%s", gotweb_url_root, gotweb_url_root[0] ? "/" : "", repos_url_path); - if (ret == -1) { - yyerror("snprintf"); - } + if (ret == -1) + fatal("snprintf"); if ((size_t)ret >= sizeof(srv->full_repos_url_path)) { - yyerror("gotweb_url_root and " + fprintf(stderr, "gotweb_url_root and " "repos_url_path too long, exceed %zd bytes", sizeof(srv->full_repos_url_path) - 1); + return -1; } } @@ -1776,8 +1782,10 @@ parse_config(const char *filename, struct gotwebd *env site->auth_config = srv->auth_config; if (site->repo_name[0] == '\0') { - yyerror("no repository defined for website " - "'%s' on server %s", url_path, srv->name); + fprintf(stderr, "no repository defined for " + "website %s' on server %s", url_path, + srv->name); + return -1; } } }