Skip to content
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

In flt_readdir(), do not write into the buffer returned by readdir() #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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