sysupdate: reject short manifest hashes

unhexmem_full() ignores whitespace, so a 64-byte manifest digest field
can decode to fewer than 32 bytes. Reject that while parsing instead.

[   83.883087] TEST-72-SYSUPDATE.sh[5995]: systemd-sysupdate: ../src/src/sysupdate/sysupdate-resource.c:581: resource_load_from_web: Assertion `h.iov_len == sizeof(instance->metadata.sha256sum)' failed.

Follow-up for 43cc7a3ef4

Assisted-by: kres (claude-opus-4-7)
Co-developed-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Luca Boccassi
2026-06-15 06:59:24 +09:00
committed by Yu Watanabe
parent 045e8f1c7b
commit 11bc593c68
2 changed files with 31 additions and 0 deletions
+5
View File
@@ -532,6 +532,11 @@ static int resource_load_from_web(
r = unhexmem_full(p, 64, /* secure= */ false, &h.iov_base, &h.iov_len);
if (r < 0)
return log_error_errno(r, "Failed to parse digest at manifest line %zu, refusing.", line_nr);
if (h.iov_len != sizeof_field(InstanceMetadata, sha256sum))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Manifest hash at line %zu decoded to %zu bytes, refusing.",
line_nr,
h.iov_len);
p += 64, left -= 64;