Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Possibility of DB corruption #1

Open
kshpytsya opened this issue Nov 23, 2023 · 0 comments
Open

Possibility of DB corruption #1

kshpytsya opened this issue Nov 23, 2023 · 0 comments

Comments

@kshpytsya
Copy link

Since it is perfectly acceptable for open to return 0 ("The return value of open() is a file descriptor, a small, nonnegative integer" 1), self.fd may be set to 0 in the following line:

self.fd = os.open(self.path, os.O_RDONLY)

This is highly possible in non-interactive Docker environment, when there is no stdin open.

Incorrect condition in the following line (which should be written as self.fd is not None instead):

if self.fd:

causes wiping of the DB via self._create_empty_db call.

Footnotes

  1. man open

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant