repart: add extra safety check that the verity signature fits in the partition we want to write

This commit is contained in:
Lennart Poettering
2023-09-25 19:07:09 +02:00
parent 8e47958423
commit 3510df0ae4

View File

@@ -4159,6 +4159,9 @@ static int partition_format_verity_sig(Context *context, Partition *p) {
if (r < 0)
return log_error_errno(r, "Failed to format verity signature JSON object: %m");
if (strlen(text)+1 > p->new_size)
return log_error_errno(SYNTHETIC_ERRNO(E2BIG), "Verity signature too long for partition: %m");
r = strgrowpad0(&text, p->new_size);
if (r < 0)
return log_error_errno(r, "Failed to pad string to %s", FORMAT_BYTES(p->new_size));