Skip to content

Commit

Permalink
Respect script limits when building executables.
Browse files Browse the repository at this point in the history
  • Loading branch information
meisterT committed Feb 22, 2024
1 parent 89fe096 commit 9d237fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion judge/build_executable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ logmsg $LOG_INFO "starting build"

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

Expand Down
5 changes: 5 additions & 0 deletions judge/judgedaemon.main.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ function fetch_executable_internal(

if ($do_compile) {
logmsg(LOG_DEBUG, "Building executable in $execdir, under 'build/'");

putenv('SCRIPTTIMELIMIT=' . djconfig_get_value('script_timelimit'));
putenv('SCRIPTMEMLIMIT=' . djconfig_get_value('script_memory_limit'));
putenv('SCRIPTFILELIMIT=' . djconfig_get_value('script_filesize_limit'));

system(LIBJUDGEDIR . '/build_executable.sh ' . dj_escapeshellarg($execdir), $retval);
if ($retval !== 0) {
return [null, "Failed to build executable in $execdir.", "$execdir/build.log"];
Expand Down

0 comments on commit 9d237fd

Please sign in to comment.