$OpenBSD: patch-src_tools_wasm2wat_cc,v 1.1 2021/05/13 05:00:36 semarie Exp $

Index: src/tools/wasm2wat.cc
--- src/tools/wasm2wat.cc.orig
+++ src/tools/wasm2wat.cc
@@ -19,6 +19,9 @@
 #include <cstdio>
 #include <cstdlib>
 
+#include <err.h>
+#include <unistd.h>
+
 #include "src/apply-names.h"
 #include "src/binary-reader.h"
 #include "src/binary-reader-ir.h"
@@ -103,6 +106,13 @@ int ProgramMain(int argc, char** argv) {
   InitStdio();
   ParseOptions(argc, argv);
 
+  if (unveil(s_infile.c_str(), "r") != 0)
+    err(1, "unveil: %s", s_infile.c_str());
+  if (!s_outfile.empty() && unveil(s_outfile.c_str(), "wc") != 0)
+    err(1, "unveil: %s", s_outfile.c_str());
+  if (pledge("stdio rpath wpath cpath", NULL) != 0)
+    err(1, "pledge");
+  
   std::vector<uint8_t> file_data;
   result = ReadFile(s_infile.c_str(), &file_data);
   if (Succeeded(result)) {
