summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-02-22 16:20:01 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-02-22 16:20:01 +0000
commit20b0938b1da4fd3f51912c4fff9da73b327b9586 (patch)
tree2df59e8f1953d184d074c0c330e5e4690e82d8a2
parent65cee38304172c6c1526f3ed7bdabf02ac60ad56 (diff)
downloadmandoc-20b0938b1da4fd3f51912c4fff9da73b327b9586.tar.gz
Pledge man.cgi(8).
Based on a more complicated patch from semarie@. Sebastien and tb@ both agree with the simplification.
-rw-r--r--cgi.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/cgi.c b/cgi.c
index b15649af..c41b3531 100644
--- a/cgi.c
+++ b/cgi.c
@@ -978,6 +978,22 @@ main(void)
const char *querystring;
int i;
+#if HAVE_PLEDGE
+ /*
+ * The "rpath" pledge could be revoked after mparse_readfd()
+ * if the file desciptor to "/footer.html" would be opened
+ * up front, but it's probably not worth the complication
+ * of the code it would cause: it would require scattering
+ * pledge() calls in multiple low-level resp_*() functions.
+ */
+
+ if (pledge("stdio rpath", NULL) == -1) {
+ warn("pledge");
+ pg_error_internal();
+ return EXIT_FAILURE;
+ }
+#endif
+
/* Poor man's ReDoS mitigation. */
itimer.it_value.tv_sec = 2;