From c9848bb7eaa73c9ac92c47062981f0111d30204a Mon Sep 17 00:00:00 2001 From: Tony Asleson Date: Wed, 30 Nov 2016 16:45:50 -0600 Subject: [PATCH] lvmdbusd: Only allow 0..N for --blackboxsize argument --- daemons/lvmdbusd/main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py index 9bf087100..17e2175b5 100644 --- a/daemons/lvmdbusd/main.py +++ b/daemons/lvmdbusd/main.py @@ -54,6 +54,14 @@ def process_request(): utils.log_error("process_request exception: \n%s" % st) +def check_bb_size(value): + v = int(value) + if v < 0: + raise argparse.ArgumentTypeError( + "positive integers only ('%s' invalid)" % value) + return v + + def main(): start = time.time() # Add simple command line handling @@ -80,7 +88,7 @@ def main(): "--blackboxsize", help="Size of the black box flight recorder, 0 to disable", default=10, - type=int, + type=check_bb_size, dest='bb_size') use_session = os.getenv('LVMDBUSD_USE_SESSION', False)