From: Lennart Poettering Date: Mon, 25 Sep 2023 17:07:09 +0000 (+0200) Subject: repart: add extra safety check that the verity signature fits in the partition we... X-Git-Tag: v255-rc1~438^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F29315%2Fhead;p=thirdparty%2Fsystemd.git repart: add extra safety check that the verity signature fits in the partition we want to write --- diff --git a/src/partition/repart.c b/src/partition/repart.c index 2cc4881ada2..da7cbe1152c 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -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));