6 #include <sys/resource.h>
9 static void setrl(int r, long lim)
13 if (getrlimit(r, &rl))
14 error("getrlimit %d: %s\n", r, strerror(errno));
16 if (setrlimit(r, &rl))
17 error("setrlimit %d: %s\n", r, strerror(errno));
22 enum {n = 8*1024*1024};
29 return error("out of memory");
30 setrl(RLIMIT_STACK, 128*1024);
32 for (i = 0; i < n; i++) s[i] = '1';
37 * stack overflow if scanf copies s on the stack (glibc)
38 * same issue with %d except then storing the conversion
39 * result is undefined behaviour
41 i = sscanf(s, "%f %c", &f, &c);
44 error("sscanf returned %d, want 2\n", i);
46 error("sscanf(longnum, \"%%f\") read %f, want inf\n", f);
48 error("sscanf(\"1\", %%c) read '%c', want '1'\n", c);