--- a/cgi.c +++ b/cgi.c @@ -879,14 +879,15 @@ int fd; int usepath; - if (-1 == (fd = open(file, O_RDONLY, 0))) { + mchars_alloc(); + mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1 | + MPARSE_VALIDATE, MANDOC_OS_OTHER, req->q.manpath); + + if (-1 == (fd = mparse_open(mp, file))) { puts("
You specified an invalid manual file.
"); return; } - mchars_alloc(); - mp = mparse_alloc(MPARSE_SO | MPARSE_UTF8 | MPARSE_LATIN1 | - MPARSE_VALIDATE, MANDOC_OS_OTHER, req->q.manpath); mparse_readfd(mp, fd, file); close(fd); meta = mparse_result(mp);