From ffef92ee0ed10551b20521f2d6e5637c8f9da798 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 8 Feb 2018 23:16:26 +0100 Subject: generate: disallow zero length generated passwords --- src/password-store.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/password-store.sh b/src/password-store.sh index e3e5659..eac5404 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -505,7 +505,8 @@ cmd_generate() { local path="$1" local length="${2:-$GENERATED_LENGTH}" check_sneaky_paths "$path" - [[ ! $length =~ ^[0-9]+$ ]] && die "Error: pass-length \"$length\" must be a number." + [[ $length =~ ^[0-9]+$ ]] || die "Error: pass-length \"$length\" must be a number." + [[ $length -gt 0 ]] || die "Error: pass-length must be greater than zero." mkdir -p -v "$PREFIX/$(dirname -- "$path")" set_gpg_recipients "$(dirname -- "$path")" local passfile="$PREFIX/$path.gpg" -- cgit v1.2.3