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

fix for stat(2) path traversal using fstat #138

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

Conversation

jaromil
Copy link

@jaromil jaromil commented May 18, 2020

Hi there!

Here is my fix to retrieve correct file information on POSX systems when along the path traversal a directory has no executable flag.

From stat(2) manpage:

"No permissions are required on the file itself, but—in the case of stat(), fstatat(), and lstat() execute (search) permission is required on all of the directories in pathname that lead to the file."

At the moment this is an incomplete fix: it breaks usage of lstat(2) on POSIX systems, due to change of the function signature passed to _file_info_().

Kindly provide feedback on how to proceed. IMHO the usage of a function pointer passed as argument of file_info is a design burden: a simple flag can be used.

ciao

p.s. for the impatient, a quick non-breaking fix is applied in the lfs version shipped in my software.

return(3);
}
#endif
if (st(fd, &info)) {
lua_pushnil(L);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should also close file inside if statement

@hishamhm
Copy link
Member

@jaromil Feel free to simplify the internals if it aids with the bugfix and preserves portability!

@jaromil
Copy link
Author

jaromil commented May 19, 2020

Thanks for your feedbacks, knowing your interest now I'll rework the PR into something more presentable and passing tests.

@hishamhm hishamhm force-pushed the master branch 2 times, most recently from 9cd10fe to f77f248 Compare June 24, 2022 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants