script: set a scricter limit on memory
This commit is contained in:
parent
d4c60dc105
commit
125521ddc1
@ -32,6 +32,9 @@
|
||||
#include <strings.h>
|
||||
#include <math.h>
|
||||
|
||||
#define ADDRESS_SPACE_LIMIT (100 * 1024 * 1024)
|
||||
#include <sys/resource.h>
|
||||
|
||||
#if defined __GNUC__
|
||||
#define ATTRIBUTE_PRINTF(x, y) __attribute__ ((format (printf, x, y)))
|
||||
#else // ! __GNUC__
|
||||
@ -2164,6 +2167,15 @@ main (int argc, char *argv[])
|
||||
freopen (NULL, "rb", stdin); setvbuf (stdin, NULL, _IOLBF, BUFSIZ);
|
||||
freopen (NULL, "wb", stdout); setvbuf (stdout, NULL, _IOLBF, BUFSIZ);
|
||||
|
||||
struct rlimit limit =
|
||||
{
|
||||
.rlim_cur = ADDRESS_SPACE_LIMIT,
|
||||
.rlim_max = ADDRESS_SPACE_LIMIT
|
||||
};
|
||||
|
||||
// Lower the memory limits to something sensible to prevent abuse
|
||||
(void) setrlimit (RLIMIT_AS, &limit);
|
||||
|
||||
read_db ();
|
||||
init_runtime_library ();
|
||||
register_handler (".", fn_dot);
|
||||
|
Loading…
Reference in New Issue
Block a user