From 65110289fa5c284883bea92ed72d2bfcdfb761ba Mon Sep 17 00:00:00 2001 From: Ashe Connor Date: Tue, 20 Nov 2018 11:20:26 +1100 Subject: Use pledge(2) on OpenBSD --- src/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main.c b/src/main.c index 8942520..904df5e 100644 --- a/src/main.c +++ b/src/main.c @@ -7,6 +7,10 @@ #include "cmark.h" #include "node.h" +#if defined(__OpenBSD__) +#include +#endif + #if defined(_WIN32) && !defined(__CYGWIN__) #include #include @@ -77,6 +81,13 @@ int main(int argc, char *argv[]) { writer_format writer = FORMAT_HTML; int options = CMARK_OPT_DEFAULT; +#if defined(__OpenBSD__) + if (pledge("stdio rpath", NULL) != 0) { + perror("pledge"); + return 1; + } +#endif + #if defined(_WIN32) && !defined(__CYGWIN__) _setmode(_fileno(stdin), _O_BINARY); _setmode(_fileno(stdout), _O_BINARY); @@ -176,6 +187,13 @@ int main(int argc, char *argv[]) { } } +#if defined(__OpenBSD__) + if (pledge("stdio", NULL) != 0) { + perror("pledge"); + return 1; + } +#endif + document = cmark_parser_finish(parser); cmark_parser_free(parser); -- cgit v1.2.3