From 3845ac135228877411ef7389908e491afca16553 Mon Sep 17 00:00:00 2001 From: Jukka Taimisto Date: Tue, 26 Oct 2021 15:45:27 +0300 Subject: [PATCH] Do not allow 0 concurrent scans in config Also unify the error messages if verify() finds invalid values --- src/config.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index dc1fbd9..3ef5804 100644 --- a/src/config.rs +++ b/src/config.rs @@ -618,14 +618,21 @@ impl Config { if self.timeout.is_none() { missing_fields.push(ARG_TIMEOUT); } - if self.concurrent_scans.is_none() { + if let Some(c) = self.concurrent_scans { + if c == 0 { + return Err(Error::Message(format!( + "invalid value for {}: Value needs to be non-zero", + ARG_CONCURRENT_SCANS + ))); + } + } else { missing_fields.push(ARG_CONCURRENT_SCANS); } if let Some(c) = self.try_count { if c == 0 { return Err(Error::Message(format!( - "Invalid {} {}, expecting non-zero positive count", - ARG_TRY_COUNT, c + "invalid value for {}: value needs to be non-zero", + ARG_TRY_COUNT ))); } } else {