From 069d183ae7f642ebbec137e247a92d18b5093175 Mon Sep 17 00:00:00 2001 From: Tudor Date: Sat, 18 Feb 2017 17:34:45 -0500 Subject: [PATCH] Compilers are unsafe, so treat them as such --- dmoj/executors/base_executor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dmoj/executors/base_executor.py b/dmoj/executors/base_executor.py index bb8aa2827..38b57207b 100644 --- a/dmoj/executors/base_executor.py +++ b/dmoj/executors/base_executor.py @@ -318,7 +318,10 @@ def get_compile_process(self): return self.TimedPopen(self.get_compile_args(), **kwargs) def get_compile_output(self, process): - return process.communicate()[1] + # Use safe_communicate because otherwise, malicious submissions can cause a compiler + # to output hundreds of megabytes of data as output before being killed by the time limit, + # which effectively murders the MySQL server waiting on the server. + return safe_communicate(process, None, outlimit=65536, errlimit=65536)[1] def get_compiled_file(self): return self._file(self.problem)