<div dir="auto"><div><div data-smartmail="gmail_signature">LHS is implicitly quoted in bash's [[.</div><div class="gmail_extra"><br><div class="gmail_quote">On Feb 9, 2018 00:54, "Bernardo da Costa" <<a href="mailto:bernardo.da-costa@polytechnique.org">bernardo.da-costa@polytechnique.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="quoted-text">On Thu, Feb 08, 2018 at 11:11:55PM +0100, mauli wrote:<br>
> Hi,<br>
><br>
> in the IRC someone was having issues with 100% CPU use when generating a<br>
> password with length 0, I found that read -r -n 0  just keeps on going.<br>
> I cannot find this behavior documented if NCHARS is set to 0.<br>
><br>
> ---<br>
> diff --git a/src/password-store.sh b/src/password-store.sh<br>
> index e3e5659..2afb51b 100755<br>
> --- a/src/password-store.sh<br>
> +++ b/src/password-store.sh<br>
> @@ -505,7 +505,7 @@ cmd_generate() {<br>
>       local path="$1"<br>
>       local length="${2:-$GENERATED_<wbr>LENGTH}"<br>
>       check_sneaky_paths "$path"<br>
> -     [[ ! $length =~ ^[0-9]+$ ]] && die "Error: pass-length \"$length\" must be a number."<br>
> +     [[ ! $length =~ ^[1-9][0-9]+$ ]] && die "Error: pass-length \"$length\" must be a number greater 0."<br>
<br>
</div>Note that this invalidates $length = 1, 2, ..., 9; the regex should have<br>
been "^[1-9][0-9]*$".<br>
<br>
Jason's commit<br>
<a href="https://git.zx2c4.com/password-store/commit/?id=ffef92ee0ed10551b20521f2d6e5637c8f9da798" rel="noreferrer" target="_blank">https://git.zx2c4.com/<wbr>password-store/commit/?id=<wbr>ffef92ee0ed10551b20521f2d6e563<wbr>7c8f9da798</a><br>
does not have this problem.<br>
<br>
<br>
By the way, should (for input security reasons) the test be made<br>
<div class="quoted-text"><br>
[[ ! "$length" =~ ^[0-9]+$ ]]<br>
<br>
</div>?<br>
<font color="#888888"><br>
--<br>
Bernardo<br>
</font><div class="elided-text"><br>
______________________________<wbr>_________________<br>
Password-Store mailing list<br>
<a href="mailto:Password-Store@lists.zx2c4.com">Password-Store@lists.zx2c4.com</a><br>
<a href="https://lists.zx2c4.com/mailman/listinfo/password-store" rel="noreferrer" target="_blank">https://lists.zx2c4.com/<wbr>mailman/listinfo/password-<wbr>store</a><br>
</div></blockquote></div><br></div></div></div>