Limit readline()

This commit is contained in:
pixeebot[bot] 2024-04-09 17:20:04 +00:00 committed by GitHub
parent a332be6a7b
commit 79073bad92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -186,7 +186,7 @@ def get_passphrase(env):
# length of 32 bytes.
backup_root = os.path.join(env["STORAGE_ROOT"], 'backup')
with open(os.path.join(backup_root, 'secret_key.txt'), encoding="utf-8") as f:
passphrase = f.readline().strip()
passphrase = f.readline(5_000_000).strip()
if len(passphrase) < 43: raise Exception("secret_key.txt's first line is too short!")
return passphrase

View File

@ -587,7 +587,7 @@ def readline(filename):
"""
with open(filename, errors='replace', encoding='utf-8') as file:
while True:
line = file.readline()
line = file.readline(5_000_000)
if not line:
break
yield line