Skip to content

Commit 44eafe0

Browse files
author
Ashe Connor
authored
use pledge(2) (commonmark#132)
1 parent d53d533 commit 44eafe0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
#include "../extensions/cmark-gfm-core-extensions.h"
1515

16+
#if defined(__OpenBSD__)
17+
#include <unistd.h>
18+
#endif
19+
1620
#if defined(_WIN32) && !defined(__CYGWIN__)
1721
#include <io.h>
1822
#include <fcntl.h>
@@ -117,6 +121,13 @@ int main(int argc, char *argv[]) {
117121
int options = CMARK_OPT_DEFAULT;
118122
int res = 1;
119123

124+
#if defined(__OpenBSD__)
125+
if (pledge("stdio rpath", NULL) != 0) {
126+
perror("pledge");
127+
return 1;
128+
}
129+
#endif
130+
120131
cmark_gfm_core_extensions_ensure_registered();
121132

122133
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -264,6 +275,13 @@ int main(int argc, char *argv[]) {
264275
}
265276
}
266277

278+
#if defined(__OpenBSD__)
279+
if (pledge("stdio", NULL) != 0) {
280+
perror("pledge");
281+
return 1;
282+
}
283+
#endif
284+
267285
document = cmark_parser_finish(parser);
268286

269287
if (!document || !print_document(document, writer, options, width, parser))

0 commit comments

Comments
 (0)