Skip to content

Commit a094c92

Browse files
committed
Do not use @ in judgedaemon, but properly check for errors.
1 parent 09c422a commit a094c92

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

judge/judgedaemon.main.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ function read_credentials(): void
3333
global $endpoints;
3434

3535
$credfile = ETCDIR . '/restapi.secret';
36-
$credentials = @file($credfile);
37-
if (!$credentials) {
38-
error("Cannot read REST API credentials file " . $credfile);
36+
if (!is_readable($credfile)) {
37+
error("REST API credentials file " . $credfile . " is not readable or does not exist.");
38+
}
39+
$credentials = file($credfile);
40+
if ($credentials === false) {
41+
error("Error reading REST API credentials file " . $credfile);
3942
}
4043
$lineno = 0;
4144
foreach ($credentials as $credential) {
@@ -1500,8 +1503,8 @@ function judge(array $judgeTask): bool
15001503
$runtime = null;
15011504
$metadata = read_metadata($passdir . '/program.meta');
15021505

1503-
if (isset($metadata['time-used'])) {
1504-
$runtime = @$metadata[$metadata['time-used']];
1506+
if (isset($metadata['time-used']) && array_key_exists($metadata['time-used'], $metadata)) {
1507+
$runtime = $metadata[$metadata['time-used']];
15051508
}
15061509

15071510
if ($result === 'compare-error') {

0 commit comments

Comments
 (0)