-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
TClingUtils: Avoid growing paths in GetFileName #10387
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
llvm::SmallString<256> headerFileName(headerFE->getName()); | ||
// Remove double ../ from the path so that the search below finds a valid | ||
// longest match and does not result in growing paths. | ||
llvm::sys::path::remove_dots(headerFileName, /*remove_dot_dot=*/true); |
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.
IIUC this will break line 3402 in the original file:
size_t lenTrailing = headerFileName.size() - (IDir->data() - headerFileName.data());
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.
Not sure, IDir
is also created referencing headerFileName
. That should be fine. The use-after-free is definitely not 😐
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.
Let’s count on a post review here if that’s still unclear
Um yeah, that's a nice use-after-free right there because |
Strip of ../ so that the search finds a valid longest match. With the upcoming upgrade of LLVM 13, this would otherwise lead to an error "File name too long" but it's already wrong now.
Starting build on |
ping @vgvassilev |
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.
LGTM!
llvm::SmallString<256> headerFileName(headerFE->getName()); | ||
// Remove double ../ from the path so that the search below finds a valid | ||
// longest match and does not result in growing paths. | ||
llvm::sys::path::remove_dots(headerFileName, /*remove_dot_dot=*/true); |
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.
Let’s count on a post review here if that’s still unclear
Strip of ../ so that the search finds a valid longest match. With the upcoming upgrade of LLVM 13, this would otherwise lead to an error "File name too long" but it's already wrong now.