Skip to content

Commit 9fa6be9

Browse files
committed
Qubes: avoid tracebacks when no more /tmp storage
Detect OSError when writing RBG files on the Qubes isolation provider. Fixes #578
1 parent 42810e0 commit 9fa6be9

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

dangerzone/conversion/errors.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ class ServerOutOfTempSpaceError(OutOfSpaceError):
124124
error_message = "The isolated environment where the document conversion take space ran out of space"
125125

126126

127+
class ClientOutOfTMPSpaceError(OutOfSpaceError):
128+
"""The client ran out of space"""
129+
130+
error_code = ERROR_SHIFT + 72
131+
error_message = (
132+
"You computer ran out of temporary storage space during the document conversion"
133+
)
134+
135+
127136
class UnexpectedConversionError(PDFtoPPMException):
128137
error_code = ERROR_SHIFT + 100
129138
error_message = "Some unexpected error occurred while converting the document"

dangerzone/isolation_provider/qubes.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,16 @@ def __convert(
135135
timeout=sw.remaining,
136136
)
137137

138-
# Wrapper code
139-
with open(f"/tmp/dangerzone/page-{page}.width", "w") as f_width:
140-
f_width.write(str(width))
141-
with open(f"/tmp/dangerzone/page-{page}.height", "w") as f_height:
142-
f_height.write(str(height))
143-
with open(f"/tmp/dangerzone/page-{page}.rgb", "wb") as f_rgb:
144-
f_rgb.write(untrusted_pixels)
145-
138+
try:
139+
# Wrapper code
140+
with open(f"/tmp/dangerzone/page-{page}.width", "w") as f_width:
141+
f_width.write(str(width))
142+
with open(f"/tmp/dangerzone/page-{page}.height", "w") as f_height:
143+
f_height.write(str(height))
144+
with open(f"/tmp/dangerzone/page-{page}.rgb", "wb") as f_rgb:
145+
f_rgb.write(untrusted_pixels)
146+
except OSError:
147+
raise errors.ClientOutOfTMPSpaceError()
146148
percentage += percentage_per_page
147149

148150
text = f"Converting page {page}/{n_pages} to pixels"

0 commit comments

Comments
 (0)