Skip to content

Commit

Permalink
Trim OTA checksum for whitespace before comparing
Browse files Browse the repository at this point in the history
The OTA checksum is base64 encoded, whitespaces at the start or end
are not part of the checksum. Simply strip them before comparing.

Fixes: #817
  • Loading branch information
agners committed Jul 19, 2024
1 parent 69bc4cb commit 9818f1b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions matter_server/server/ota/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,12 @@ async def download_update(self, update_desc: dict) -> None:
# Download finished, check checksum if necessary
if checksum_alg:
checksum = b64encode(checksum_alg.digest()).decode("ascii")
if checksum != update_desc["otaChecksum"]:
checksum_expected = update_desc["otaChecksum"].strip()
if checksum != checksum_expected:
LOGGER.error(
"Checksum mismatch for file '%s', expected: %s, got: %s",
"Checksum mismatch for file '%s', expected: '%s', got: '%s'",
file_name,
update_desc["otaChecksum"],
checksum_expected,
checksum,
)
await loop.run_in_executor(None, file_path.unlink)
Expand Down

0 comments on commit 9818f1b

Please sign in to comment.