aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2024-05-08 01:43:44 -0500
committerRob Landley <rob@landley.net>2024-05-08 01:43:44 -0500
commit6800a95ef32826e753881802a2c126c59d451397 (patch)
tree2d2478648b4b8b0dcf0680320926eae822eedcb8
parent1ef5414e940a4e67564cf57dc8dd376d695a8911 (diff)
downloadtoybox-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.c2
-rwxr-xr-xtests/find.test5
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 6a4a77dd..9561848a 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -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' \
+ '' ''