m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-02-08 23:16:26 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-02-08 23:17:40 +0100
commitffef92ee0ed10551b20521f2d6e5637c8f9da798 (patch)
treea3a18d67750f96fe5088df98fa13855e86915c25 /src
parent94ac2ba2c6baa268a64cb4e96421f6f1bf96fd96 (diff)
generate: disallow zero length generated passwords
Diffstat (limited to 'src')
-rwxr-xr-xsrc/password-store.sh3
1 files changed, 2 insertions, 1 deletions
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"