]> git.cameronkatri.com Git - mandoc.git/commitdiff
When the MAN_DIR/manpath.conf configuration file does not exist or is empty,
authorIngo Schwarze <schwarze@openbsd.org>
Fri, 18 Jul 2014 14:46:25 +0000 (14:46 +0000)
committerIngo Schwarze <schwarze@openbsd.org>
Fri, 18 Jul 2014 14:46:25 +0000 (14:46 +0000)
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 <semarie-openbsd at latrappe dot fr>,
messages tweaked by me.

cgi.c

diff --git a/cgi.c b/cgi.c
index e246e7fdcd9b3dd3f6cf61f9b60afb85e905f9ff..8f539b46d3a38e7fb9ca27c6aeaef5cfa9494847 100644 (file)
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-/*     $Id: cgi.c,v 1.73 2014/07/13 15:38:36 schwarze Exp $ */
+/*     $Id: cgi.c,v 1.74 2014/07/18 14:46:25 schwarze Exp $ */
 /*
  * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2014 Ingo Schwarze <schwarze@usta.de>
@@ -970,8 +970,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])
@@ -980,4 +984,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);
+       }
 }