Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion dmoj/cptbox/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
_SYSCALL_INDICIES[PTBOX_ABI_ARM64] = 5

FREEBSD = sys.platform.startswith('freebsd')
BAD_SECCOMP = sys.platform == 'linux' and tuple(map(int, os.uname().release.partition('-')[0].split('.'))) < (4, 8)

_address_bits = {
PTBOX_ABI_X86: 32,
Expand All @@ -44,6 +43,23 @@
HandlerCallback = Callable[[Debugger], bool]


def is_bad_seccomp() -> bool:
try:
version_parts = os.uname().release.partition('-')[0].split('.')
clean_parts = []
for part in version_parts:
clean_part = ''.join(c for c in part if c.isdigit())
if clean_part:
clean_parts.append(int(clean_part))
return sys.platform == 'linux' and tuple(clean_parts) < (4, 8)
except (ValueError, IndexError):
# Default to assuming bad seccomp if we can't parse
return True


BAD_SECCOMP = is_bad_seccomp()


class MaxLengthExceeded(ValueError):
pass

Expand Down
8 changes: 5 additions & 3 deletions dmoj/executors/autoconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ def main():
else:
if not args.silent:
print_ansi(
f'#ansi[{feedback or "Success"}](green|bold)'
if success
else f'#ansi[{feedback or "Failed"}](red|bold)',
(
f'#ansi[{feedback or "Success"}](green|bold)'
if success
else f'#ansi[{feedback or "Failed"}](red|bold)'
),
file=sys.stderr,
)

Expand Down
4 changes: 1 addition & 3 deletions dmoj/tests/test_int_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,4 @@ def test_parse_string_long(self):
def test_parse_int(self):
self.assertEqual(int(1), 1)
self.assertEqual(int(-1337), -1337)
self.assertEqual(
int(10**builtin_int_patch.INT_MAX_NUMBER_DIGITS), 10**builtin_int_patch.INT_MAX_NUMBER_DIGITS
)
self.assertEqual(int(10**builtin_int_patch.INT_MAX_NUMBER_DIGITS), 10**builtin_int_patch.INT_MAX_NUMBER_DIGITS)
Loading