Qubes: close qrexec stdin and stout

Ensure a server cannon keep the client hannging if more data than
necessary is sent. This applies to container and the Qubes
implmentation.
This commit is contained in:
deeplow 2023-08-21 19:25:55 +01:00
parent 874b8865e2
commit d6bce4dec5
No known key found for this signature in database
GPG key ID: 577982871529A52A

View file

@ -46,6 +46,7 @@ def read_debug_text(p: subprocess.Popen) -> str:
"""Read arbitrarily long text (for debug purposes)""" """Read arbitrarily long text (for debug purposes)"""
if p.stderr: if p.stderr:
untrusted_text = p.stderr.read(MAX_CONVERSION_LOG_CHARS) untrusted_text = p.stderr.read(MAX_CONVERSION_LOG_CHARS)
p.stderr.close()
return untrusted_text.decode("ascii", errors="replace") return untrusted_text.decode("ascii", errors="replace")
else: else:
return "" return ""
@ -135,6 +136,9 @@ class Qubes(IsolationProvider):
text = f"Converting page {page}/{n_pages} to pixels" text = f"Converting page {page}/{n_pages} to pixels"
self.print_progress_trusted(document, False, text, percentage) self.print_progress_trusted(document, False, text, percentage)
# Ensure nothing else is read after all bitmaps are obtained
p.stdout.close() # type: ignore [union-attr]
# TODO handle leftover code input # TODO handle leftover code input
text = "Converted document to pixels" text = "Converted document to pixels"
self.print_progress_trusted(document, False, text, percentage) self.print_progress_trusted(document, False, text, percentage)