From 35208f702f0a5e4ebe70d651efd75770f176b2d0 Mon Sep 17 00:00:00 2001
From: "W. Felix Handte" <w@felixhandte.com>
Date: Wed, 29 Dec 2021 18:42:32 -0800
Subject: [PATCH] Add Test Validating Stack is not Executable in playTests.sh

---
 tests/playTests.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tests/playTests.sh b/tests/playTests.sh
index a772b61ff..e1da24a4b 100755
--- a/tests/playTests.sh
+++ b/tests/playTests.sh
@@ -304,6 +304,15 @@ zstd -d -f tmp_corrupt.zst --no-check
 zstd -d -f tmp_corrupt.zst --check --no-check # final flag overrides
 zstd -d -f tmp.zst --no-check
 
+if [ "$isWindows" = false ]; then
+  if [ -n "$(which readelf)" ]; then
+    println "test: check if binary has executable stack"
+    file "$ZSTD_BIN"
+    readelf -lW "$ZSTD_BIN"
+    readelf -lW "$ZSTD_BIN" | grep 'GNU_STACK .* RW ' || die "zstd binary has executable stack!"
+  fi
+fi
+
 println "\n===> zstdgrep tests"
 ln -sf "$ZSTD_BIN" zstdcat
 rm -f tmp_grep
-- 
GitLab