Make big endian explicit in int to bytes

Fix issues in older distros that don't yet support python 3.11 where
endianness was not a default argument [1]. This is in response to CI
failures [2].

[1]: https://docs.python.org/3/library/stdtypes.html#int.to_bytes
[2]: https://app.circleci.com/pipelines/github/freedomofpress/dangerzone/2186/workflows/e340ca21-85ce-42b6-9bc3-09e66f96684a/jobs/27380y
This commit is contained in:
deeplow 2024-01-15 11:32:30 +00:00
parent 5e169a832b
commit f3032a7142
No known key found for this signature in database
GPG key ID: 577982871529A52A
3 changed files with 3 additions and 3 deletions

View file

@ -76,7 +76,7 @@ class DangerzoneConverter:
@classmethod
def _write_int(cls, num: int, file: TextIO = sys.stdout) -> None:
cls._write_bytes(num.to_bytes(2, signed=False), file=file)
cls._write_bytes(num.to_bytes(2, "big", signed=False), file=file)
# ==== ASYNC METHODS ====
# We run sync methods in async wrappers, because pure async methods are more difficult:

View file

@ -36,7 +36,7 @@ def read_int(f: IO[bytes], timeout: float) -> int:
untrusted_int = read_bytes(f, 2, timeout)
if len(untrusted_int) != 2:
raise errors.InterruptedConversionException()
return int.from_bytes(untrusted_int, signed=False)
return int.from_bytes(untrusted_int, "big", signed=False)
def read_debug_text(f: IO[bytes], size: int) -> str:

View file

@ -97,7 +97,7 @@ class Qubes(IsolationProvider):
# 1. The size of the Python zipfile, so that the server can know when to
# stop.
# 2. The Python zipfile itself.
bufsize_bytes = len(temp_file.getvalue()).to_bytes(4)
bufsize_bytes = len(temp_file.getvalue()).to_bytes(4, "big")
wpipe.write(bufsize_bytes)
wpipe.write(temp_file.getvalue())