sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit 6eec2eb3b48870435c9d729e8cf6dac44e2c3744
parent e1c56a6321707b8c34244564d18bb831f9c224f7
Author: Pieter Kockx <pieterkockx@gmail.com>
Date:   Wed,  4 Oct 2017 02:25:41 +0200

tr: Fix infinite loop

When `makeset` got a string containing square brackets
followed by at least one extra character, e.g. "[abc]d",
it entered an infinite loop because it was assumed
`j` could not exceed `len` without having been equal to `len`.
It can, however, when `m == len` and subsequently `j = m + 1`.

Diffstat:
tr.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tr.c b/tr.c @@ -85,7 +85,7 @@ makeset(char *str, struct range **set, int (**check)(Rune)) if (rstr[i] == '[') { j = i; nextbrack: - if (j == len) + if (j >= len) goto literal; for (m = j; m < len; m++) if (rstr[m] == ']') {