Re: man.cgi: clean exit when absent or empty manpath.conf
Sébastien Marie wrote on Fri, Jul 18, 2014 at 08:50:17AM +0200:
> Starting to play with man.cgi (src/usr.bin/mandoc/cgi.c),
Thank you for testing.
> it seems that man.cgi will segfault if configuration file
> is absent or empty.
> Here a patch that display error message and 505, like when MAN_DIR is
> Note: the segfault occurs in cgi.c:224 (http_parse), that assume
> req->p is not NULL (req->q.manpath = req->p).
> The diff use the same style that when MAN_DIR is invalid (cgi.c:917),
That is all very much to the point, thank you for finding and
analysing the bug and providing a correct patch.
I have tweaked the message strings a bit, committed your patch
to both cvs.openbsd.org and mdocml.bsd.lv, and updated the installed
man.cgi programs on both www.openbsd.org and mdocml.bsd.lv.
> but that could be improved using err(3) ?
Well, i do like the err(3) family of functions for its clarity
and conciseness, but so far, we have refrained from using them
in mandoc for portability reasons. While it is trivial to
provide compat functions for systems not having them, it is
just as trivial to use fprintf(3), strerror(3), and exit(3)
for now, so this is kind of a bikeshed. I guess at some point
i will switch to using err(3), even POSIX considers adding them
unless i heard an unfounded rumour...