[Patch] Fix issue for pass generate 0

Bernardo da Costa bernardo.da-costa at polytechnique.org
Fri Feb 9 00:53:27 CET 2018


On Thu, Feb 08, 2018 at 11:11:55PM +0100, mauli wrote:
> Hi,
> 
> in the IRC someone was having issues with 100% CPU use when generating a
> password with length 0, I found that read -r -n 0  just keeps on going.
> I cannot find this behavior documented if NCHARS is set to 0.
> 
> ---
> diff --git a/src/password-store.sh b/src/password-store.sh
> index e3e5659..2afb51b 100755
> --- a/src/password-store.sh
> +++ b/src/password-store.sh
> @@ -505,7 +505,7 @@ 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 =~ ^[1-9][0-9]+$ ]] && die "Error: pass-length \"$length\" must be a number greater 0."

Note that this invalidates $length = 1, 2, ..., 9; the regex should have
been "^[1-9][0-9]*$".

Jason's commit
https://git.zx2c4.com/password-store/commit/?id=ffef92ee0ed10551b20521f2d6e5637c8f9da798
does not have this problem.


By the way, should (for input security reasons) the test be made

[[ ! "$length" =~ ^[0-9]+$ ]]

?

-- 
Bernardo



More information about the Password-Store mailing list