aboutsummaryrefslogtreecommitdiff
path: root/catgets/tst-catgets.c
diff options
context:
space:
mode:
authorPaul Pluzhnikov <ppluzhnikov@google.com>2015-08-08 15:53:03 -0700
committerPaul Pluzhnikov <ppluzhnikov@google.com>2015-08-08 15:53:03 -0700
commit0f58539030e436449f79189b6edab17d7479796e (patch)
tree1f43408602c20aab6c51e6c69cb1a82cc6b82eb2 /catgets/tst-catgets.c
parent74bc0c3a16e3c8f138e29a284e84d16474b65a8e (diff)
downloadglibc-0f58539030e436449f79189b6edab17d7479796e.zip
glibc-0f58539030e436449f79189b6edab17d7479796e.tar.gz
glibc-0f58539030e436449f79189b6edab17d7479796e.tar.bz2
Fix BZ #17905
Diffstat (limited to 'catgets/tst-catgets.c')
-rw-r--r--catgets/tst-catgets.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/catgets/tst-catgets.c b/catgets/tst-catgets.c
index a0a4089..140de72 100644
--- a/catgets/tst-catgets.c
+++ b/catgets/tst-catgets.c
@@ -1,7 +1,10 @@
+#include <assert.h>
#include <mcheck.h>
#include <nl_types.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <sys/resource.h>
static const char *msgs[] =
@@ -12,6 +15,33 @@ static const char *msgs[] =
};
#define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
+
+/* Test for unbounded alloca. */
+static int
+do_bz17905 (void)
+{
+ char *buf;
+ struct rlimit rl;
+ nl_catd result;
+
+ const int sz = 1024 * 1024;
+
+ getrlimit (RLIMIT_STACK, &rl);
+ rl.rlim_cur = sz;
+ setrlimit (RLIMIT_STACK, &rl);
+
+ buf = malloc (sz + 1);
+ memset (buf, 'A', sz);
+ buf[sz] = '\0';
+ setenv ("NLSPATH", buf, 1);
+
+ result = catopen (buf, NL_CAT_LOCALE);
+ assert (result == (nl_catd) -1);
+
+ free (buf);
+ return 0;
+}
+
#define ROUNDS 5
static int
@@ -62,6 +92,7 @@ do_test (void)
}
}
+ result += do_bz17905 ();
return result;
}