| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include <config.h> |
| 20 |
|
| 21 |
#include <stdio.h> |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#if HAVE_GETRLIMIT && HAVE_SETRLIMIT && !defined __CHKP__ |
| 27 |
|
| 28 |
#include <stdlib.h> |
| 29 |
#include <sys/types.h> |
| 30 |
#include <sys/time.h> |
| 31 |
#include <sys/resource.h> |
| 32 |
#include <string.h> |
| 33 |
#include <errno.h> |
| 34 |
|
| 35 |
int |
| 36 |
main (int argc, char *argv[]) |
| 37 |
{ |
| 38 |
struct rlimit limit; |
| 39 |
int arg; |
| 40 |
int ret; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
#ifdef RLIMIT_DATA |
| 45 |
if (getrlimit (RLIMIT_DATA, &limit) < 0) |
| 46 |
return 77; |
| 47 |
if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 10000000) |
| 48 |
limit.rlim_max = 10000000; |
| 49 |
limit.rlim_cur = limit.rlim_max; |
| 50 |
if (setrlimit (RLIMIT_DATA, &limit) < 0) |
| 51 |
return 77; |
| 52 |
#endif |
| 53 |
|
| 54 |
#ifdef RLIMIT_AS |
| 55 |
if (getrlimit (RLIMIT_AS, &limit) < 0) |
| 56 |
return 77; |
| 57 |
if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 10000000) |
| 58 |
limit.rlim_max = 10000000; |
| 59 |
limit.rlim_cur = limit.rlim_max; |
| 60 |
if (setrlimit (RLIMIT_AS, &limit) < 0) |
| 61 |
return 77; |
| 62 |
#endif |
| 63 |
|
| 64 |
#ifdef RLIMIT_STACK |
| 65 |
if (getrlimit (RLIMIT_STACK, &limit) < 0) |
| 66 |
return 77; |
| 67 |
if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 10000000) |
| 68 |
limit.rlim_max = 10000000; |
| 69 |
limit.rlim_cur = limit.rlim_max; |
| 70 |
if (setrlimit (RLIMIT_STACK, &limit) < 0) |
| 71 |
return 77; |
| 72 |
#endif |
| 73 |
|
| 74 |
arg = atoi (argv[1]); |
| 75 |
switch (arg) |
| 76 |
{ |
| 77 |
case 0: |
| 78 |
{ |
| 79 |
void *memory = malloc (10000000); |
| 80 |
if (memory == NULL) |
| 81 |
return 1; |
| 82 |
memset (memory, 17, 10000000); |
| 83 |
return 78; |
| 84 |
} |
| 85 |
case 1: |
| 86 |
ret = fprintf (stdout, "%.10000000f", 1.0); |
| 87 |
return !(ret == 10000002 || (ret < 0 && errno == ENOMEM)); |
| 88 |
case 2: |
| 89 |
ret = fprintf (stdout, "%.10000000f", -1.0); |
| 90 |
return !(ret == 10000003 || (ret < 0 && errno == ENOMEM)); |
| 91 |
case 3: |
| 92 |
ret = fprintf (stdout, "%.10000000e", 1.0); |
| 93 |
return !(ret >= 10000006 || (ret < 0 && errno == ENOMEM)); |
| 94 |
case 4: |
| 95 |
ret = fprintf (stdout, "%.10000000d", 1); |
| 96 |
return !(ret == 10000000 || (ret < 0 && errno == ENOMEM)); |
| 97 |
case 5: |
| 98 |
ret = fprintf (stdout, "%.10000000d", -1); |
| 99 |
return !(ret == 10000001 || (ret < 0 && errno == ENOMEM)); |
| 100 |
case 6: |
| 101 |
ret = fprintf (stdout, "%.10000000u", 1); |
| 102 |
return !(ret == 10000000 || (ret < 0 && errno == ENOMEM)); |
| 103 |
} |
| 104 |
return 0; |
| 105 |
} |
| 106 |
|
| 107 |
#else |
| 108 |
|
| 109 |
int |
| 110 |
main (int argc, char *argv[]) |
| 111 |
{ |
| 112 |
return 77; |
| 113 |
} |
| 114 |
|
| 115 |
#endif |