diff options
author | Rob Landley <rob@landley.net> | 2024-05-08 01:43:44 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2024-05-08 01:43:44 -0500 |
commit | 6800a95ef32826e753881802a2c126c59d451397 (patch) | |
tree | 2d2478648b4b8b0dcf0680320926eae822eedcb8 | |
parent | 1ef5414e940a4e67564cf57dc8dd376d695a8911 (diff) | |
download | toybox-6800a95ef32826e753881802a2c126c59d451397.tar.gz |
Ray Gardner pointed out we were adding the +4 to the wrong side of
the strlower() check for unicode facepalm. With test.
-rw-r--r-- | lib/lib.c | 2 | ||||
-rwxr-xr-x | tests/find.test | 5 |
2 files changed, 6 insertions, 1 deletions
@@ -432,7 +432,7 @@ char *strlower(char *s) // Case conversion can expand utf8 representation, but with extra mlen // space above we should basically never need to realloc - if (mlen+4 > (len = new-try)) continue; + if (mlen > (len = new-try)+4) continue; try = xrealloc(try, mlen = len+16); new = try+len; } diff --git a/tests/find.test b/tests/find.test index 862edc93..e026d7b5 100755 --- a/tests/find.test +++ b/tests/find.test @@ -160,3 +160,8 @@ ln -s one dir/three testing '-size implies -type f' 'find dir -size -1M | sort' \ 'dir/one\ndir/two\n' '' '' rm -rf dir + +utf8locale +testing 'strlower edge case' \ + 'touch aaaaaⱥⱥⱥⱥⱥⱥⱥⱥⱥ; find . -iname aaaaaȺȺȺȺȺȺȺȺȺ' './aaaaaⱥⱥⱥⱥⱥⱥⱥⱥⱥ\n' \ + '' '' |