Skip to content

Commit 18a26c7

Browse files
committed
Respect script limits when building executables.
1 parent 2c2fe35 commit 18a26c7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

judge/build_executable.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ logmsg $LOG_INFO "starting build"
7676

7777
exitcode=0
7878
$GAINROOT "$RUNGUARD" ${DEBUG:+-v} -u "$RUNUSER" -g "$RUNGROUP" \
79-
-r "$CHROOTDIR" -d '/build' --no-core -- \
79+
-r "$CHROOTDIR" -d '/build' \
80+
-m $SCRIPTMEMLIMIT -t $SCRIPTTIMELIMIT --no-core -f $SCRIPTFILELIMIT -s $SCRIPTFILELIMIT \
81+
-- \
8082
'./build' > 'build.log' 2>&1 || \
8183
exitcode=$?
8284

judge/judgedaemon.main.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ function fetch_executable_internal(
439439

440440
if ($do_compile) {
441441
logmsg(LOG_DEBUG, "Building executable in $execdir, under 'build/'");
442+
443+
putenv('SCRIPTTIMELIMIT=' . djconfig_get_value('script_timelimit'));
444+
putenv('SCRIPTMEMLIMIT=' . djconfig_get_value('script_memory_limit'));
445+
putenv('SCRIPTFILELIMIT=' . djconfig_get_value('script_filesize_limit'));
446+
442447
system(LIBJUDGEDIR . '/build_executable.sh ' . dj_escapeshellarg($execdir), $retval);
443448
if ($retval !== 0) {
444449
return [null, "Failed to build executable in $execdir.", "$execdir/build.log"];

0 commit comments

Comments
 (0)