mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-12-01 12:20:02 +00:00
Wild this hasn't been caught until now.
Because the exact ordering of the comparison in lfs_bd_cmp is a bit
ambiguous, lfs_dir_find_match returned the wrong result when filenames
were equal, and only differed in length.
For example:
- cmp("a", "aa") should be LFS_CMP_LT
- cmp("aaa", "aa") should be LFS_CMP_GT
We're quite lucky that none of the littlefs internals currently depend
on the sorted order, otherwise we'd probably be stuck with this weird
ordering for backwards compatibility reasons...
Fixed, and added some test cases over directory ordering to prevent
regression in the future.
Found by andriyndev