Skip to content

Commit d1343ad

Browse files
committed
Make maximum file size configurable.
1 parent ea16881 commit d1343ad

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

cms/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ def __init__(self):
6868
self.use_cgroups = True
6969
self.sandbox_implementation = 'isolate'
7070

71+
# Sandbox.
72+
self.max_file_size = 1048576
73+
7174
# WebServers.
7275
self.secret_key_default = "8e045a51e4b102ea803c06f92841a1fb"
7376
self.secret_key = self.secret_key_default

cms/grading/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33

44
# Contest Management System - http://cms-dev.github.io/
5-
# Copyright © 2010-2014 Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
5+
# Copyright © 2010-2015 Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
66
# Copyright © 2010-2014 Stefano Maggiolo <s.maggiolo@gmail.com>
77
# Copyright © 2010-2012 Matteo Boscariol <boscarim@hotmail.com>
88
# Copyright © 2013 Bernard Blackham <bernard@largestprime.net>
@@ -36,7 +36,7 @@
3636

3737
from sqlalchemy.orm import joinedload
3838

39-
from cms import \
39+
from cms import config, \
4040
LANG_C, LANG_CPP, LANG_PASCAL, LANG_PYTHON, LANG_PHP, LANG_JAVA, \
4141
SCORE_MODE_MAX
4242
from cms.db import Submission
@@ -391,7 +391,7 @@ def evaluation_step_before_run(sandbox, command,
391391
sandbox.timeout = 0
392392
sandbox.wallclock_timeout = 0
393393
sandbox.address_space = memory_limit * 1024
394-
sandbox.fsize = memory_limit * 1024
394+
sandbox.fsize = config.max_file_size
395395

396396
if stdin_redirect is not None:
397397
sandbox.stdin_file = stdin_redirect

config/cms.conf.sample

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@
5858

5959

6060

61+
"_section": "Sandbox",
62+
63+
"_help": "Do not allow contestants' solutions to write files bigger",
64+
"_help": "than this size (expressed in KB; defaults to 1 GB).",
65+
"max_file_size": 1048576,
66+
67+
68+
6169
"_section": "WebServers",
6270

6371
"_help": "This key is used to encode information that can be seen",

0 commit comments

Comments
 (0)