From 1b28fb2d1a0eea36d7890f2294b7244d51698c66 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 22 Nov 2019 22:04:41 +0100 Subject: [PATCH] donate-cpu.py: Verify argument for jobs (-jN) (#2386) Yesterday, I observed that some client with a wrong jobs setting (only "-j") requested one package after another and always uploaded results where it only said that the argument "-j" is invalid for Cppcheck. This check should avoid such cases where results are overwritten with useless data and the server is kept busy for nothing. --- tools/donate-cpu.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index cdc13b823..5109a3504 100755 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -45,6 +45,10 @@ for arg in sys.argv[1:]: stop_time = arg[-5:] print('Stop time:' + stop_time) elif arg.startswith('-j'): + if not re.match(r'-j\d+', arg): + print('Argument "{}" is invalid.'.format(arg)) + print('"-j" must be followed by a positive number.') + sys.exit(1) jobs = arg print('Jobs:' + jobs[2:]) elif arg.startswith('--package='):