On Tue May 11, 2021 at 12:28:00PM +0200, Sebastien Marie wrote:
> On Sun, May 09, 2021 at 12:28:03PM +0200, Sebastien Marie wrote:
> > Hi,
> >
> > The following diff update lang/wabt to 1.0.23.
>
> New diff with futher changes:
>
> - Fabian told me privately to remove him as MAINTAINER
>
> - I patched command-line tools with unveil and pledge (tools are used
> to inspect wasm files, which tend to be untrusted files from
> internet)
>
> Comments or OK ?
OK rsadowski
> --
> Sebastien Marie
>
>
> diff 7180b7eb7a5ecb0c5a59d457eb8191f1571bdb8d
> /home/semarie/repos/openbsd/ports
> blob - 9b9cda8d58eb01e9f60a8709532e605f0d573b5a
> file + lang/wabt/Makefile
> --- lang/wabt/Makefile
> +++ lang/wabt/Makefile
> @@ -2,27 +2,35 @@
>
> COMMENT = WebAssembly binary toolkit
>
> -GH_ACCOUNT = WebAssembly
> -GH_PROJECT = wabt
> -GH_TAGNAME = 1.0.8
> +DISTNAME = wabt-${V}
> +V = 1.0.23
>
> CATEGORIES = lang
>
> -MAINTAINER = Fabian Raetz <[email protected]>
> +HOMEPAGE = https://github.com/WebAssembly/wabt/
>
> # Apache 2.0
> PERMIT_PACKAGE = Yes
>
> +# use pledge()
> WANTLIB = ${COMPILER_LIBCXX} c m
>
> +MASTER_SITES =
> https://github.com/WebAssembly/wabt/releases/download/${V}/
> +
> +EXTRACT_SUFX = .tar.xz
> +
> # C++11
> COMPILER = base-clang ports-gcc
>
> -MODULES = devel/cmake
> +MODULES = devel/cmake \
> + lang/python
>
> -CONFIGURE_ARGS = -DBUILD_TESTS=OFF \
> - -DRUN_RE2C=OFF
> +MODPY_RUNDEP = No
>
> -NO_TEST = Yes
> +TEST_TARGET = check
>
> +# disable skip-stack-guard-page test: SEGFAULT
> +pre-test:
> + -mv ${WRKSRC}/test/wasm2c/spec/skip-stack-guard-page.txt{,.disable}
> +
> .include <bsd.port.mk>
> blob - a974db92ccc8ee84f5270e4aee6655bc66df8be0
> file + lang/wabt/distinfo
> --- lang/wabt/distinfo
> +++ lang/wabt/distinfo
> @@ -1,2 +1,2 @@
> -SHA256 (wabt-1.0.8.tar.gz) = /6rW3lz7xb4MfnjM1MC0S70eWeqjjPUPQkXKBNvaiD4=
> -SIZE (wabt-1.0.8.tar.gz) = 954541
> +SHA256 (wabt-1.0.23.tar.xz) = /EIQKeGWTdashGz0JwroEwo6TZ1VO/QcF1pW2o5CI+4=
> +SIZE (wabt-1.0.23.tar.xz) = 1925328
> blob - /dev/null
> file + lang/wabt/patches/patch-src_tools_wasm-decompile_cc
> --- /dev/null
> +++ lang/wabt/patches/patch-src_tools_wasm-decompile_cc
> @@ -0,0 +1,29 @@
> +$OpenBSD$
> +
> +Index: src/tools/wasm-decompile.cc
> +--- src/tools/wasm-decompile.cc.orig
> ++++ src/tools/wasm-decompile.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"
> +@@ -70,6 +73,13 @@ int ProgramMain(int argc, char** argv) {
> + });
> + parser.Parse(argc, argv);
> + }
> ++
> ++ if (unveil(infile.c_str(), "r") != 0)
> ++ err(1, "unveil: %s", infile.c_str());
> ++ if (!outfile.empty() && unveil(outfile.c_str(), "wc") != 0)
> ++ err(1, "unveil: %s", outfile.c_str());
> ++ if (pledge("stdio rpath wpath cpath", NULL) != 0)
> ++ err(1, "pledge");
> +
> + std::vector<uint8_t> file_data;
> + Result result = ReadFile(infile.c_str(), &file_data);
> blob - /dev/null
> file + lang/wabt/patches/patch-src_tools_wasm-interp_cc
> --- /dev/null
> +++ lang/wabt/patches/patch-src_tools_wasm-interp_cc
> @@ -0,0 +1,27 @@
> +$OpenBSD$
> +
> +Index: src/tools/wasm-interp.cc
> +--- src/tools/wasm-interp.cc.orig
> ++++ src/tools/wasm-interp.cc
> +@@ -22,6 +22,9 @@
> + #include <string>
> + #include <vector>
> +
> ++#include <err.h>
> ++#include <unistd.h>
> ++
> + #include "src/binary-reader.h"
> + #include "src/error-formatter.h"
> + #include "src/feature.h"
> +@@ -326,6 +329,11 @@ int ProgramMain(int argc, char** argv) {
> +
> + ParseOptions(argc, argv);
> +
> ++ if (unveil(s_infile, "r") != 0)
> ++ err(1, "unveil: %s", s_infile);
> ++ if (pledge("stdio rpath", NULL) != 0)
> ++ err(1, "pledge");
> ++
> + wabt::Result result = ReadAndRunModule(s_infile);
> + return result != wabt::Result::Ok;
> + }
> blob - /dev/null
> file + lang/wabt/patches/patch-src_tools_wasm-objdump_cc
> --- /dev/null
> +++ lang/wabt/patches/patch-src_tools_wasm-objdump_cc
> @@ -0,0 +1,25 @@
> +$OpenBSD$
> +
> +Index: src/tools/wasm-objdump.cc
> +--- src/tools/wasm-objdump.cc.orig
> ++++ src/tools/wasm-objdump.cc
> +@@ -18,6 +18,9 @@
> + #include <cstdlib>
> + #include <cstring>
> +
> ++#include <err.h>
> ++#include <unistd.h>
> ++
> + #include "src/common.h"
> + #include "src/option-parser.h"
> + #include "src/stream.h"
> +@@ -117,6 +120,9 @@ Result dump_file(const char* filename) {
> +
> + int ProgramMain(int argc, char** argv) {
> + InitStdio();
> ++
> ++ if (pledge("stdio rpath", NULL) != 0)
> ++ err(1, "pledge");
> +
> + ParseOptions(argc, argv);
> + if (!s_objdump_options.headers && !s_objdump_options.details &&
> blob - /dev/null
> file + lang/wabt/patches/patch-src_tools_wasm-opcodecnt_cc
> --- /dev/null
> +++ lang/wabt/patches/patch-src_tools_wasm-opcodecnt_cc
> @@ -0,0 +1,29 @@
> +$OpenBSD$
> +
> +Index: src/tools/wasm-opcodecnt.cc
> +--- src/tools/wasm-opcodecnt.cc.orig
> ++++ src/tools/wasm-opcodecnt.cc
> +@@ -23,6 +23,9 @@
> + #include <map>
> + #include <vector>
> +
> ++#include <err.h>
> ++#include <unistd.h>
> ++
> + #include "src/binary-reader.h"
> + #include "src/binary-reader-opcnt.h"
> + #include "src/option-parser.h"
> +@@ -151,6 +154,13 @@ void WriteCountsWithImmediates(Stream& stream,
> + int ProgramMain(int argc, char** argv) {
> + InitStdio();
> + ParseOptions(argc, argv);
> ++
> ++ if (unveil(s_infile, "r") != 0)
> ++ err(1, "unveil: %s", s_infile);
> ++ if (s_outfile != NULL && unveil(s_outfile, "wc") != 0)
> ++ err(1, "unveil: %s", s_outfile);
> ++ if (pledge("stdio rpath wpath cpath", NULL) != 0)
> ++ err(1, "pledge");
> +
> + std::vector<uint8_t> file_data;
> + Result result = ReadFile(s_infile, &file_data);
> blob - /dev/null
> file + lang/wabt/patches/patch-src_tools_wasm-strip_cc
> --- /dev/null
> +++ lang/wabt/patches/patch-src_tools_wasm-strip_cc
> @@ -0,0 +1,27 @@
> +$OpenBSD$
> +
> +Index: src/tools/wasm-strip.cc
> +--- src/tools/wasm-strip.cc.orig
> ++++ src/tools/wasm-strip.cc
> +@@ -14,6 +14,9 @@
> + * limitations under the License.
> + */
> +
> ++#include <err.h>
> ++#include <unistd.h>
> ++
> + #include "src/binary.h"
> + #include "src/binary-reader.h"
> + #include "src/binary-reader-nop.h"
> +@@ -85,6 +88,11 @@ int ProgramMain(int argc, char** argv) {
> + InitStdio();
> + ParseOptions(argc, argv);
> +
> ++ if (unveil(s_filename.c_str(), "rwc") != 0)
> ++ err(1, "unveil: %s", s_filename.c_str());
> ++ if (pledge("stdio rpath wpath cpath", NULL) != 0)
> ++ err(1, "pledge");
> ++
> + std::vector<uint8_t> file_data;
> + result = ReadFile(s_filename.c_str(), &file_data);
> + if (Succeeded(result)) {
> blob - /dev/null
> file + lang/wabt/patches/patch-src_tools_wasm-validate_cc
> --- /dev/null
> +++ lang/wabt/patches/patch-src_tools_wasm-validate_cc
> @@ -0,0 +1,27 @@
> +$OpenBSD$
> +
> +Index: src/tools/wasm-validate.cc
> +--- src/tools/wasm-validate.cc.orig
> ++++ src/tools/wasm-validate.cc
> +@@ -19,6 +19,9 @@
> + #include <cstdio>
> + #include <cstdlib>
> +
> ++#include <err.h>
> ++#include <unistd.h>
> ++
> + #include "src/binary-reader.h"
> + #include "src/binary-reader-ir.h"
> + #include "src/error-formatter.h"
> +@@ -71,6 +74,11 @@ 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 (pledge("stdio rpath", NULL) != 0)
> ++ err(1, "pledge");
> +
> + std::vector<uint8_t> file_data;
> + result = ReadFile(s_infile.c_str(), &file_data);
> blob - /dev/null
> file + lang/wabt/patches/patch-src_tools_wasm2c_cc
> --- /dev/null
> +++ lang/wabt/patches/patch-src_tools_wasm2c_cc
> @@ -0,0 +1,25 @@
> +$OpenBSD$
> +
> +Index: src/tools/wasm2c.cc
> +--- src/tools/wasm2c.cc.orig
> ++++ src/tools/wasm2c.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"
> +@@ -108,6 +111,9 @@ int ProgramMain(int argc, char** argv) {
> +
> + InitStdio();
> + ParseOptions(argc, argv);
> ++
> ++ 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);
> blob - /dev/null
> file + lang/wabt/patches/patch-src_tools_wasm2wat_cc
> --- /dev/null
> +++ lang/wabt/patches/patch-src_tools_wasm2wat_cc
> @@ -0,0 +1,29 @@
> +$OpenBSD$
> +
> +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)) {
> blob - /dev/null
> file + lang/wabt/patches/patch-src_tools_wast2json_cc
> --- /dev/null
> +++ lang/wabt/patches/patch-src_tools_wast2json_cc
> @@ -0,0 +1,25 @@
> +$OpenBSD$
> +
> +Index: src/tools/wast2json.cc
> +--- src/tools/wast2json.cc.orig
> ++++ src/tools/wast2json.cc
> +@@ -21,6 +21,9 @@
> + #include <cstdio>
> + #include <string>
> +
> ++#include <err.h>
> ++#include <unistd.h>
> ++
> + #include "config.h"
> +
> + #include "src/binary-writer.h"
> +@@ -102,6 +105,9 @@ int ProgramMain(int argc, char** argv) {
> +
> + ParseOptions(argc, argv);
> +
> ++ if (pledge("stdio rpath wpath cpath", NULL) != 0)
> ++ err(1, "pledge");
> ++
> + std::vector<uint8_t> file_data;
> + Result result = ReadFile(s_infile, &file_data);
> + std::unique_ptr<WastLexer> lexer = WastLexer::CreateBufferLexer(
> blob - /dev/null
> file + lang/wabt/patches/patch-src_tools_wat-desugar_cc
> --- /dev/null
> +++ lang/wabt/patches/patch-src_tools_wat-desugar_cc
> @@ -0,0 +1,29 @@
> +$OpenBSD$
> +
> +Index: src/tools/wat-desugar.cc
> +--- src/tools/wat-desugar.cc.orig
> ++++ src/tools/wat-desugar.cc
> +@@ -20,6 +20,9 @@
> + #include <cstdio>
> + #include <cstdlib>
> +
> ++#include <err.h>
> ++#include <unistd.h>
> ++
> + #include "config.h"
> +
> + #include "src/apply-names.h"
> +@@ -83,6 +86,13 @@ static void ParseOptions(int argc, char** argv) {
> + int ProgramMain(int argc, char** argv) {
> + InitStdio();
> + ParseOptions(argc, argv);
> ++
> ++ if (unveil(s_infile, "r") != 0)
> ++ err(1, "unveil: %s", s_infile);
> ++ if (s_outfile != NULL && unveil(s_outfile, "wc") != 0)
> ++ err(1, "unveil: %s", s_outfile);
> ++ if (pledge("stdio rpath wpath cpath", NULL) != 0)
> ++ err(1, "pledge");
> +
> + std::vector<uint8_t> file_data;
> + Result result = ReadFile(s_infile, &file_data);
> blob - /dev/null
> file + lang/wabt/patches/patch-src_tools_wat2wasm_cc
> --- /dev/null
> +++ lang/wabt/patches/patch-src_tools_wat2wasm_cc
> @@ -0,0 +1,29 @@
> +$OpenBSD$
> +
> +Index: src/tools/wat2wasm.cc
> +--- src/tools/wat2wasm.cc.orig
> ++++ src/tools/wat2wasm.cc
> +@@ -21,6 +21,9 @@
> + #include <cstdio>
> + #include <string>
> +
> ++#include <err.h>
> ++#include <unistd.h>
> ++
> + #include "config.h"
> +
> + #include "src/binary-writer.h"
> +@@ -125,6 +128,13 @@ int ProgramMain(int argc, char** argv) {
> + InitStdio();
> +
> + ParseOptions(argc, argv);
> ++
> ++ if (unveil(s_infile, "r") != 0)
> ++ err(1, "unveil: %s", s_infile);
> ++ 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 result = ReadFile(s_infile, &file_data);
> blob - 855d16f9ebf6655c68b3db4ec73025a449b2e360
> file + lang/wabt/pkg/DESCR
> --- lang/wabt/pkg/DESCR
> +++ lang/wabt/pkg/DESCR
> @@ -14,6 +14,9 @@ wasm-objdump:
> wasm-interp:
> decode and run a WebAssembly binary file using a stack-based interpreter
>
> +wasm-decompile:
> + decompile a wasm binary into readable C-like syntax
> +
> wat-desugar:
> parse .wat text form as supported by the spec interpreter
> (s-expressions, flat syntax, or mixed) and print "canonical" flat format
> blob - 400b3e9b625f5b6ff617d5a2c527e91ab6373cda
> file + lang/wabt/pkg/PLIST
> --- lang/wabt/pkg/PLIST
> +++ lang/wabt/pkg/PLIST
> @@ -1,5 +1,6 @@
> @comment $OpenBSD: PLIST,v 1.2 2019/02/04 14:13:04 rapha Exp $
> @bin bin/spectest-interp
> +@bin bin/wasm-decompile
> @bin bin/wasm-interp
> @bin bin/wasm-objdump
> @bin bin/wasm-opcodecnt
> @@ -10,7 +11,11 @@
> @bin bin/wast2json
> @bin bin/wat-desugar
> @bin bin/wat2wasm
> +include/wasm-rt-impl.h
> +include/wasm-rt.h
> +@static-lib lib/libwasm-rt-impl.a
> @man man/man1/spectest-interp.1
> +@man man/man1/wasm-decompile.1
> @man man/man1/wasm-interp.1
> @man man/man1/wasm-objdump.1
> @man man/man1/wasm-opcodecnt.1
>