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

~/.local/share/tig/history may not be used since version 2.5.6 #1215

Closed
yan12125 opened this issue Jul 15, 2022 · 3 comments · Fixed by #1217
Closed

~/.local/share/tig/history may not be used since version 2.5.6 #1215

yan12125 opened this issue Jul 15, 2022 · 3 comments · Fixed by #1217

Comments

@yan12125
Copy link
Contributor

Since 2.5.6 (d308b74, particularly), if $XDG_DATA_HOME is valid, tig runs mkdir(dirname(path), 0777);. However, dirname() may modify the string pointed to by path [1]. If that happens, path no longer points to the desired history file.

For example, on Arch LInux, dirname() changes path from

"/home/yen/.local/share/tig/history\0"

to

"/home/yen/.local/share/tig\0history\0"

The following open() fails as path is now a directory, and the fallback ~/.tig_history is used.

By the way, is it a good idea to use permission 0777?

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/dirname.html

@yan12125
Copy link
Contributor Author

Figured out a fix: #1217

@koutcher
Copy link
Collaborator

@yan12125 , thanks for reporting and fixing the issue. To my dismay, macOS version of dirname() does not behave the same as Linux version, so I missed that. 0777 is further restricted by the user's umask, I don't think we have a reason to be more restrictive.

@yan12125
Copy link
Contributor Author

0777 is further restricted by the user's umask, I don't think we have a reason to be more restrictive.

Got it!

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