-
Notifications
You must be signed in to change notification settings - Fork 3k
littlefs: Fix issue with trailing dots in file paths #6774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Paths such as the following were causing issues: /tea/hottea/. /tea/hottea/.. Unfortunately the existing structure for path lookup didn't make it very easy to introduce proper handling in this case without duplicating the entire skip logic for paths. So the lfs_dir_find function had to be restructured a bit. One odd side-effect of this is that now lfs_dir_find includes the initial fetch operation. This kinda breaks the fetch -> op pattern of the dir functions, but does come with a nice code size reduction.
@@ -783,26 +783,19 @@ static int lfs_dir_find(lfs_t *lfs, lfs_dir_t *dir, | |||
lfs_entry_t *entry, const char **path) { | |||
const char *pathname = *path; | |||
size_t pathlen; | |||
entry->d.type = LFS_TYPE_DIR; | |||
entry->d.elen = sizeof(entry->d) - 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will sizeof(entry->d)
be ever < 4? Will that be corner case considering elen
is uint8_t?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the prefix for the entry stored on disk is a 4 byte header. If entry->d is less than 4, than the struct is malformed.
Also GCC is actually smart enough to warn on underflow for constants like these.
/morph build |
Build : SUCCESSBuild number : 1897 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 1544 |
Test : SUCCESSBuild number : 1714 |
Description
Paths such as the following were causing issues:
/tea/hottea/.
/tea/hottea/..
Unfortunately the existing structure for path lookup didn't make it very easy to introduce proper handling in this case without duplicating the entire skip logic for paths. So the lfs_dir_find function had to be restructured a bit.
One odd side-effect of this is that now lfs_dir_find includes the initial fetch operation. This kinda breaks the fetch -> op pattern of the dir functions, but does come with a nice code size reduction.
related littlefs-project/littlefs#51
cc @deepikabhavnani, @kegilbert
Pull request type