diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-11-23 10:36:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-23 10:36:40 -0500 |
commit | f0793895eefc8ca14499831a24abee549a5af53e (patch) | |
tree | 6f48f10c4861c8240c170ebe735e81a94bcb97d4 /src/main.c | |
parent | b1556b3407a4349b9a1f4f58d8677eda0ead09c1 (diff) | |
parent | 0d6062b80621cd52500b69c3fc0f1018e9aba7ad (diff) |
Merge pull request #278 from github/upstream-pledge
Use pledge(2) on OpenBSD
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -7,6 +7,14 @@ #include "cmark.h" #include "node.h" +#if defined(__OpenBSD__) +# include <sys/param.h> +# if OpenBSD >= 201605 +# define USE_PLEDGE +# include <unistd.h> +# endif +#endif + #if defined(_WIN32) && !defined(__CYGWIN__) #include <io.h> #include <fcntl.h> @@ -77,6 +85,13 @@ int main(int argc, char *argv[]) { writer_format writer = FORMAT_HTML; int options = CMARK_OPT_DEFAULT; +#ifdef USE_PLEDGE + 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 +191,13 @@ int main(int argc, char *argv[]) { } } +#ifdef USE_PLEDGE + if (pledge("stdio", NULL) != 0) { + perror("pledge"); + return 1; + } +#endif + document = cmark_parser_finish(parser); cmark_parser_free(parser); |