summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorMichael Kuhn <suraia@ikkoku.de>2017-09-15 15:43:42 +0200
committerAdam J. Stewart <ajstewart426@gmail.com>2017-09-15 08:43:42 -0500
commitcba1ddff4ae6ad51f9b1445a69e5f93dc69196f1 (patch)
treed2f655cf1528b02053cabbe686ad325a0900eba4 /var
parentabc0c65d03bb9632efb6c5e49f0b39eb2880461c (diff)
downloadspack-cba1ddff4ae6ad51f9b1445a69e5f93dc69196f1.tar.gz
spack-cba1ddff4ae6ad51f9b1445a69e5f93dc69196f1.tar.bz2
spack-cba1ddff4ae6ad51f9b1445a69e5f93dc69196f1.tar.xz
spack-cba1ddff4ae6ad51f9b1445a69e5f93dc69196f1.zip
ncl: Fix buffer overflow in ymake-filter (#5357)
Fixes a problem in ymake-filter: The line buffer is currently hardcoded to be 2048 bytes large but some Makefiles contain lines longer than that. This caused the Makefiles to sometimes not be generated, consequently failing parts of the build.
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/ncl/package.py2
-rw-r--r--var/spack/repos/builtin/packages/ncl/ymake-filter.patch33
2 files changed, 35 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/ncl/package.py b/var/spack/repos/builtin/packages/ncl/package.py
index 49ebbc8f47..1d338bcd9c 100644
--- a/var/spack/repos/builtin/packages/ncl/package.py
+++ b/var/spack/repos/builtin/packages/ncl/package.py
@@ -43,6 +43,8 @@ class Ncl(Package):
patch('spack_ncl.patch')
# Make ncl compile with hdf5 1.10
patch('hdf5.patch')
+ # ymake-filter's buffer may overflow
+ patch('ymake-filter.patch')
# This installation script is implemented according to this manual:
# http://www.ncl.ucar.edu/Download/build_from_src.shtml
diff --git a/var/spack/repos/builtin/packages/ncl/ymake-filter.patch b/var/spack/repos/builtin/packages/ncl/ymake-filter.patch
new file mode 100644
index 0000000000..915e82035f
--- /dev/null
+++ b/var/spack/repos/builtin/packages/ncl/ymake-filter.patch
@@ -0,0 +1,33 @@
+--- ncl_ncarg-6.4.0/config/ymake-filter.c.orig 2017-02-23 20:11:55.000000000 +0100
++++ ncl_ncarg-6.4.0/config/ymake-filter.c 2017-09-13 14:52:34.800989229 +0200
+@@ -150,13 +150,29 @@
+ getcppline()
+ {
+ int c;
+- static char buf[2048];
++ static int s = 2048;
++ static char *buf = NULL;
+ char *p;
+
++ if (buf == NULL)
++ {
++ buf = malloc(s);
++ }
++
+ p = buf;
+
+ do
+ {
++ if (p >= buf + s)
++ {
++ char* old = buf;
++
++ /* Need to increase the size of buf. */
++ s += 1024;
++ buf = realloc(buf, s);
++ p = buf + (p - old);
++ }
++
+ switch(c = getchar())
+ {
+ /*