]> git.ipfire.org Git - thirdparty/systemd.git/commit
dissect: guard against ssize_t overflow in LUKS2 header parser
authorTristanInSec <tristan.mtn@gmail.com>
Mon, 18 May 2026 17:30:02 +0000 (13:30 -0400)
committerTristanInSec <tristan.mtn@gmail.com>
Mon, 18 May 2026 17:30:02 +0000 (13:30 -0400)
commit08c281304cd6fd7bf20f5eb7aaa81c7ee4283b0c
tree6b82b1169027c7a1e103da24a87ce9dc635758a9
parent6080d1cc42b674515ac31f783a15477f47a28e92
dissect: guard against ssize_t overflow in LUKS2 header parser

The json_len variable is ssize_t, but the subtraction
be64toh(header.hdr_len) - LUKS2_FIXED_HDR_SIZE can yield a value
exceeding SSIZE_MAX when hdr_len is a large crafted value. This causes
signed integer overflow and a subsequent oversized malloc() that fails
with -ENOMEM, producing a misleading out-of-memory error.

Add an explicit check against SSIZE_MAX before the cast to ssize_t.
src/shared/dissect-image.c