summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAshe Connor <ashe@kivikakk.ee>2018-11-20 11:20:26 +1100
committerAshe Connor <ashe@kivikakk.ee>2018-11-20 11:20:26 +1100
commit65110289fa5c284883bea92ed72d2bfcdfb761ba (patch)
treef0c11ed433b51fb97d9f586b739aa5f516c42b21 /src
parentb1556b3407a4349b9a1f4f58d8677eda0ead09c1 (diff)
Use pledge(2) on OpenBSD
Diffstat (limited to 'src')
-rw-r--r--src/main.c18
1 files changed, 18 insertions, 0 deletions
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 <unistd.h>
+#endif
+
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <io.h>
#include <fcntl.h>
@@ -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);