Skip to content

Conversation

@dechamps
Copy link

When adjusting file names, flt_readdir() assumes that de->d_name points to a buffer that has sufficient size to accommodate the new name. However, readdir() does not makes any guarantee about that at all.

In practice, I've seen de->d_name pointing to tightly packed memory, such that overwriting past the original name ends up corrupting data in the directory stream, leading to erratic undefined behaviour. (In my case, the directory offset became corrupted, leading to an infinite directory scanning loop.)

This commit fixes the issue by copying the name into some local buffer before making changes to it. Also, I took the liberty to sprinkle some more debug statements while I'm at it.

When adjusting file names, flt_readdir() assumes that the de->d_name
points to a buffer that has sufficient size to accomodate the new name.
However, readdir() does not makes any guarantee about that at all.

In practice, I've seen de->d_name pointing to tightly packed memory,
such that overwriting past the original name ends up corrupting data in
the directory stream, leading to erratic undefined behavior. (In my
case, the directory offset became corrupted, leading to an infinite
directory scanning loop.)

This commit fixes the issue by copying the name into some local buffer
before making changes to it. Also, I took the liberty to sprinkle some
more debug statements while I'm at it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant