summaryrefslogtreecommitdiffstats
path: root/cgi.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-07-18 14:46:25 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-07-18 14:46:25 +0000
commitd6b0c874c2cb135687f01f289844fc55b7fe06f1 (patch)
tree863e139f236de88521b0afa016018712ffa5c885 /cgi.c
parent220e4280121438a1e183a70d29be33f27c9dcae1 (diff)
downloadmandoc-d6b0c874c2cb135687f01f289844fc55b7fe06f1.tar.gz
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 <semarie-openbsd at latrappe dot fr>, messages tweaked by me.
Diffstat (limited to 'cgi.c')
-rw-r--r--cgi.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/cgi.c b/cgi.c
index 6430ba63..eebb7b41 100644
--- a/cgi.c
+++ b/cgi.c
@@ -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);
+ }
}