diff options
Diffstat (limited to 'catgets/tst-catgets.c')
-rw-r--r-- | catgets/tst-catgets.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/catgets/tst-catgets.c b/catgets/tst-catgets.c index a0a408936b..140de722c8 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; } |