]> git.cameronkatri.com Git - mandoc.git/commitdiff
More thoroughly reject direct access to unintended files, such that
authorIngo Schwarze <schwarze@openbsd.org>
Wed, 19 Apr 2017 01:00:03 +0000 (01:00 +0000)
committerIngo Schwarze <schwarze@openbsd.org>
Wed, 19 Apr 2017 01:00:03 +0000 (01:00 +0000)
URIs like http://man.openbsd.org/OpenBSD-current/mandoc.db and
http://man.openbsd.org/OpenBSD-current/man1/ do not cause display
of garbage.

cgi.c

diff --git a/cgi.c b/cgi.c
index da638dcfb0406d76c9d94613c80af71537a5f929..eeccd4ea8124439289e34b9db245507ad6553d0d 100644 (file)
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-/*     $Id: cgi.c,v 1.153 2017/03/18 16:48:24 schwarze Exp $ */
+/*     $Id: cgi.c,v 1.154 2017/04/19 01:00:03 schwarze Exp $ */
 /*
  * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwarze@usta.de>
@@ -1073,7 +1073,8 @@ main(void)
 
        if (*path != '\0') {
                parse_path_info(&req, path);
-               if (req.q.manpath == NULL || access(path, F_OK) == -1)
+               if (req.q.manpath == NULL || req.q.sec == NULL ||
+                   *req.q.query == '\0' || access(path, F_OK) == -1)
                        path = "";
        } else if ((querystring = getenv("QUERY_STRING")) != NULL)
                parse_query_string(&req, querystring);