diff --git a/judge/judgedaemon.main.php b/judge/judgedaemon.main.php index cb10a0db0f..b4385ac4c8 100644 --- a/judge/judgedaemon.main.php +++ b/judge/judgedaemon.main.php @@ -487,10 +487,14 @@ function fetch_executable_internal( return [$execrunpath, null, null]; } -$options = getopt("dv:n:hVe:j:t:", ["diskspace-error"]); -// FIXME: getopt doesn't return FALSE on parse failure as documented! -if ($options===false) { - echo "Error: parsing options failed.\n"; +$shortoptions = "dv:n:hVe:j:t:"; +$regex = "^([a-zA-Z0-9]:{0,2})*$" +if (preg_match($regex, $shortoptions) !== 1) { + echo "Error: short options format specified is invalid.\n"; +} +$options = getopt($shortoptions, ["diskspace-error"]); +if ($options===false || !is_array($argv)) { + echo "Error: parsing options failed.\nPlease check: `register_argc_arg` in php.ini.\n"; usage(); } if (isset($options['v'])) {