Skip to content

Commit ec9cd33

Browse files
committed
better dos protection
1 parent 640d355 commit ec9cd33

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎v3/web_exec.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
import sys
1919

2020

21-
# set ~50MB limit on virtual memory to protect against memory bombs such as:
21+
# set ~300MB limit on virtual memory AND a 10-second CPU time limit
22+
# to protect against memory bombs such as:
2223
#
2324
# x = 2
2425
# while True: x = x*x
2526
import resource
26-
resource.setrlimit(resource.RLIMIT_AS, (50000000,50000000))
27+
resource.setrlimit(resource.RLIMIT_AS, (300000000, 300000000))
28+
resource.setrlimit(resource.RLIMIT_CPU, (10, 10))
2729

2830

2931
# set to true if you want to log queries in DB_FILE

0 commit comments

Comments
 (0)