From de65174757d08bdd001709db7a5364981e6ad168 Mon Sep 17 00:00:00 2001 From: schwarze Date: Fri, 18 Jul 2014 14:46:20 +0000 Subject: [PATCH] When the MAN_DIR/manpath.conf configuration file does not exist or is empty, log the problem, hand the pg_error_internal() error page to the client, and exit(3) in a controlled way instead of stumbling on and segfaulting later. Patch from Sebastien Marie , messages tweaked by me. --- usr.bin/mandoc/cgi.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/usr.bin/mandoc/cgi.c b/usr.bin/mandoc/cgi.c index 24bcb3e795c..0ddc41c6d48 100644 --- a/usr.bin/mandoc/cgi.c +++ b/usr.bin/mandoc/cgi.c @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.13 2014/07/13 15:38:06 schwarze Exp $ */ +/* $Id: cgi.c,v 1.14 2014/07/18 14:46:20 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -966,8 +966,12 @@ pathgen(struct req *req) char *dp; size_t dpsz; - if (NULL == (fp = fopen("manpath.conf", "r"))) - return; + if (NULL == (fp = fopen("manpath.conf", "r"))) { + fprintf(stderr, "%s/manpath.conf: %s\n", + MAN_DIR, strerror(errno)); + pg_error_internal(); + exit(EXIT_FAILURE); + } while (NULL != (dp = fgetln(fp, &dpsz))) { if ('\n' == dp[dpsz - 1]) @@ -976,4 +980,10 @@ pathgen(struct req *req) (req->psz + 1) * sizeof(char *)); req->p[req->psz++] = mandoc_strndup(dp, dpsz); } + + if ( req->p == NULL ) { + fprintf(stderr, "%s/manpath.conf is empty\n", MAN_DIR); + pg_error_internal(); + exit(EXIT_FAILURE); + } } -- 2.20.1