ruki 4 years ago
parent
commit
8314e68f74
2 changed files with 38 additions and 0 deletions
  1. 15 0
      packages/m/m4/patches/1.4.18/secure_snprintf.patch
  2. 23 0
      packages/m/m4/xmake.lua

+ 15 - 0
packages/m/m4/patches/1.4.18/secure_snprintf.patch

@@ -0,0 +1,15 @@
+With format string strictness, High Sierra also enforces that %n isn't used
+in dynamic format strings, but we should just disable its use on darwin in
+general.
+
+--- a/lib/vasnprintf.c.orig	2017-06-22 15:19:15.000000000 -0700
++++ b/lib/vasnprintf.c	2017-06-22 15:20:20.000000000 -0700
+@@ -4869,7 +4869,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *
+ #endif
+                   *fbp = dp->conversion;
+ #if USE_SNPRINTF
+-# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
++# if !defined(__APPLE__) && !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+                 fbp[1] = '%';
+                 fbp[2] = 'n';
+                 fbp[3] = '\0';

+ 23 - 0
packages/m/m4/xmake.lua

@@ -0,0 +1,23 @@
+package("m4")
+
+    set_kind("binary")
+    set_homepage("https://www.gnu.org/software/m4")
+    set_description("Macro processing language")
+
+    add_urls("https://ftp.gnu.org/gnu/m4/m4-$(version).tar.xz",
+             "https://ftpmirror.gnu.org/m4/m4-$(version).tar.xz")
+    add_versions("1.4.18", "f2c1e86ca0a404ff281631bdc8377638992744b175afb806e25871a24a934e07")
+
+    if is_plat("macosx") then
+        -- fix crash from usage of %n in dynamic format strings on High Sierra
+        -- patch credit to Jeremy Huddleston Sequoia <[email protected]>
+        add_patches("1.4.18", path.join(os.scriptdir(), "patches", "1.4.18", "secure_snprintf.patch"), "c0a408fbffb7255fcc75e26bd8edab116fc81d216bfd18b473668b7739a4158e")
+    end
+
+    on_install("macosx", "linux", function (package)
+        import("package.tools.autoconf").install(package, {"--disable-dependency-tracking"})
+    end)
+
+    on_test(function (package)
+        os.vrun("m4 --version")
+    end)