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

use it to get salty #16

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

use it to get salty #16

wants to merge 1 commit into from

Conversation

jfelipeco
Copy link

added some salt

Comment on lines +15 to +17
if Path(PATH).exists():
with open(PATH, "rt") as f:
pwdb = json.load(f)
Copy link

Choose a reason for hiding this comment

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

Doing the existence check separately and then opening the file is not good, because it introduces a TOCTOU race. Instead, the correct way is to try to open the file, and catch the exception if that fails:

try:
   … open(PATH, 'rt') …
except IOError:
   return {}

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.

2 participants