source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: When the MAN_DIR/manpath.conf configuration file does not exist
@ 2014-07-18 14:46 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-07-18 14:46 UTC (permalink / raw)
  To: source

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        cgi.c

Revision Data
-------------
Index: cgi.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/cgi.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -Lcgi.c -Lcgi.c -u -p -r1.73 -r1.74
--- cgi.c
+++ 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])
@@ -979,5 +983,11 @@ pathgen(struct req *req)
 		req->p = mandoc_realloc(req->p,
 		    (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);
 	}
 }
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-07-18 14:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-18 14:46 mdocml: When the MAN_DIR/manpath.conf configuration file does not exist schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).