From 643288e4ba436f039b817bfe18b9ea68bf3b09a0 Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Thu, 16 Oct 2025 20:21:08 +0200 Subject: [PATCH] Do not use `@` in judgedaemon, but properly check for errors. --- judge/judgedaemon.main.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/judge/judgedaemon.main.php b/judge/judgedaemon.main.php index 64d782a329..3ad5f06028 100644 --- a/judge/judgedaemon.main.php +++ b/judge/judgedaemon.main.php @@ -33,9 +33,12 @@ function read_credentials(): void global $endpoints; $credfile = ETCDIR . '/restapi.secret'; - $credentials = @file($credfile); - if (!$credentials) { - error("Cannot read REST API credentials file " . $credfile); + if (!is_readable($credfile)) { + error("REST API credentials file " . $credfile . " is not readable or does not exist."); + } + $credentials = file($credfile); + if ($credentials === false) { + error("Error reading REST API credentials file " . $credfile); } $lineno = 0; foreach ($credentials as $credential) { @@ -1500,8 +1503,8 @@ function judge(array $judgeTask): bool $runtime = null; $metadata = read_metadata($passdir . '/program.meta'); - if (isset($metadata['time-used'])) { - $runtime = @$metadata[$metadata['time-used']]; + if (isset($metadata['time-used']) && array_key_exists($metadata['time-used'], $metadata)) { + $runtime = $metadata[$metadata['time-used']]; } if ($result === 'compare-error') {