[Patch] Fix issue for pass generate 0

Jason A. Donenfeld Jason at zx2c4.com
Fri Feb 9 01:45:04 CET 2018


LHS is implicitly quoted in bash's [[.

On Feb 9, 2018 00:54, "Bernardo da Costa" <
bernardo.da-costa at polytechnique.org> wrote:

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

_______________________________________________
Password-Store mailing list
Password-Store at lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/password-store
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20180209/f10c79a5/attachment.html>


More information about the Password-Store mailing list