From dde62454eaa649914ff1c1fae851083d939edc5d Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Sat, 11 Jun 2022 23:08:39 +0200 Subject: [PATCH] Added argument checks to forbid negative input --- src/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 89f84f5..1bf07a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -63,21 +63,25 @@ int main(int argc, char* argv[]) { case 'u': valid += upper; min_upper = std::atoi(optarg); + if (min_upper < 0) throw std::runtime_error("minimum amout of upper case must be zero or more"); noflags = false; break; case 'l': valid += lower; min_lower = std::atoi(optarg); + if (min_upper < 0) throw std::runtime_error("minimum amout of lower case must be zero or more"); noflags = false; break; case 'd': valid += digits; min_digits = std::atoi(optarg); + if (min_upper < 0) throw std::runtime_error("minimum amout of digits must be zero or more"); noflags = false; break; case 's': valid += symbols; min_symbols = std::atoi(optarg); + if (min_upper < 0) throw std::runtime_error("minimum amout of symbols must be zero or more"); noflags = false; break; case 'S':