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:
committed by
Yu Watanabe
parent
045e8f1c7b
commit
11bc593c68
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user