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

Files are opened, but not closed explicitly #31

Open
disconnect3d opened this issue Jul 26, 2021 · 1 comment · Fixed by #34
Open

Files are opened, but not closed explicitly #31

disconnect3d opened this issue Jul 26, 2021 · 1 comment · Fixed by #34

Comments

@disconnect3d
Copy link

disconnect3d commented Jul 26, 2021

There are 5 instances when a file is opened to be read, but it is not closed explicitly. Because of it, there is a risk the file won't be closed and so a file descriptor limit can be exceeded (causing a program crash), depending on the given Python interpreter implementation.

Those instances can be found e.g. with ripgrep:

$ rg open
Apps.py
32:            files['binary'] = open(binary, 'rb')
43:            files['binary'] = open(binary, 'rb')

CustomConfigurationProfiles.py
23:        files = {'mobileconfig': open(mobileconfig, 'rb')}
39:            files['mobileconfig'] = open(mobileconfig, 'rb')

PushCertificate.py
23:        files = {'file': open(file, 'rb')}

Those cases should be changed to use the with statement so they explicitly .close() the file when the function returns or when an exception is thrown.

@rickheil
Copy link
Collaborator

rickheil commented Dec 7, 2023

Re-opening, see context in #34 for what needs to be done still.

@rickheil rickheil reopened this Dec 7, 2023
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 a pull request may close this issue.

2 participants