From 419ff51e758eba6be1ced3e9a820e19d3a29d0f9 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 20 Jun 2022 03:35:19 -0400 Subject: [PATCH] Properly handle exception for non-integer input with pass_gen() Former-commit-id: b2c4bd2cd8cf7db4516f47a48bde46610d2e9f5c [formerly 964561b33b6680c7446205fcf065332e02034dd1] Former-commit-id: c92d23fa9ee173e5e0540ecbb060b1edf8ec05c9 --- bin/sshyp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/sshyp b/bin/sshyp index ead2e49..9cd7cff 100755 --- a/bin/sshyp +++ b/bin/sshyp @@ -130,7 +130,12 @@ def pass_gen(): if __special < __min_special: __gen = _pass_gen_function(__complexity, __length) return __gen - _length = int(input('password length: ')) + try: + _length = int(input('password length: ')) + except ValueError: + print(f"\n\u001b[38;5;9merror: a non-integer value was input for password length\u001b[0m\n") + _gen = pass_gen() + return _gen if _length > 840: _length = 840 print('\n\u001b[38;5;9mpassword length has been limited to the maximum of 840 characters\u001b[0m\n')