Skip to content

Various bugs in base dir matching #327

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

Closed
mattmccutchen-cci opened this issue Nov 5, 2020 · 1 comment · Fixed by #412
Closed

Various bugs in base dir matching #327

mattmccutchen-cci opened this issue Nov 5, 2020 · 1 comment · Fixed by #412
Assignees

Comments

@mattmccutchen-cci
Copy link
Member

mattmccutchen-cci commented Nov 5, 2020

If a file outside the base dir is referenced via a .. path component in an include directory (e.g., -I option) or an #include path, 3C thinks that /absolute/path/to/my/base/dir/../foo.checked.c is still under /absolute/path/to/my/base/dir and writes the file. This is dangerous.

I'd guess there's a similar problem with symlinks. We should probably be using the equivalent of realpath.

@mattmccutchen-cci
Copy link
Member Author

Another bug I found today: 3C thinks that /path/to/foo.c is under /path/to/foo. We need to match whole path components. Maybe appending a path separator to the base dir is enough?

I'll keep all these bugs in the same GitHub issue since they seem likely to be fixed all at once.

@mattmccutchen-cci mattmccutchen-cci changed the title Base dir does not handle .. components in include paths correctly Various bugs in base dir matching Jan 25, 2021
@mattmccutchen-cci mattmccutchen-cci self-assigned this Feb 2, 2021
mattmccutchen-cci added a commit that referenced this issue Feb 8, 2021
mattmccutchen-cci added a commit that referenced this issue Feb 8, 2021
Also change the unimplemented canWrite constraints case from a typedef
to a crazy #include in anticipation of #408.
mattmccutchen-cci added a commit that referenced this issue Feb 13, 2021
- Add -output-dir option to write updated files to a directory structure
  parallel to the base dir (#347). When -output-dir is used, a source
  file outside the base dir can't be handled because there is no way to
  compute its output path. For consistency, this is now an error even
  when -output-dir is not used.

- Convert all 3C regression tests from -output-postfix to -output-dir to
  avoid leaving temporary files in the clang/test/3C directory (#378).

- Expand "3c -help" documentation. In particular, direct the user to pass
  "--" when they don't want to use a compilation database to avoid
  accidentally using unwanted compiler options and suppress the warning
  if no compilation database is found (#343).

- For consistency, have stdout mode output the main file even if it is
  unchanged (#328).

- Fix bugs in matching of file paths against the base dir (#327).

- Other minor bug fixes: see the pull request description for details.

Co-authored-by: John Kastner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants