From: Yu Watanabe Date: Thu, 3 Apr 2025 16:15:19 +0000 (+0900) Subject: sbsign: rename WIN_CERTIFICATE -> WIN_CERTIFICATE_HEADER and drop trailing flexible... X-Git-Tag: v258-rc1~910^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a8d4be01f437f811eaa42e58ee8d73efccb1c74b;p=thirdparty%2Fsystemd.git sbsign: rename WIN_CERTIFICATE -> WIN_CERTIFICATE_HEADER and drop trailing flexible array To allow building sbsign with -Werror=flex-array-member-not-at-end. --- diff --git a/src/fundamental/efi-fundamental.h b/src/fundamental/efi-fundamental.h index de7ae6cd8a4..f72290e1b3f 100644 --- a/src/fundamental/efi-fundamental.h +++ b/src/fundamental/efi-fundamental.h @@ -36,11 +36,10 @@ typedef struct { uint32_t dwLength; uint16_t wRevision; uint16_t wCertificateType; - uint8_t bCertificate[]; -} WIN_CERTIFICATE; +} WIN_CERTIFICATE_HEADER; typedef struct { - WIN_CERTIFICATE Hdr; + WIN_CERTIFICATE_HEADER Hdr; EFI_GUID CertType; uint8_t CertData[]; } WIN_CERTIFICATE_UEFI_GUID; diff --git a/src/sbsign/sbsign.c b/src/sbsign/sbsign.c index b2f0d861ce1..74e05d4b400 100644 --- a/src/sbsign/sbsign.c +++ b/src/sbsign/sbsign.c @@ -669,18 +669,18 @@ static int verb_sign(int argc, char *argv[], void *userdata) { end += n; } - uint32_t certsz = offsetof(WIN_CERTIFICATE, bCertificate) + sigsz; + uint32_t certsz = sizeof(WIN_CERTIFICATE_HEADER) + sigsz; n = pwrite(dstfd, - &(WIN_CERTIFICATE) { + &(WIN_CERTIFICATE_HEADER) { .wRevision = htole16(0x200), .wCertificateType = htole16(0x0002), /* PKCS7 signedData */ .dwLength = htole32(ROUND_UP(certsz, 8)), }, - sizeof(WIN_CERTIFICATE), + sizeof(WIN_CERTIFICATE_HEADER), end); if (n < 0) return log_error_errno(errno, "Failed to write certificate header: %m"); - if (n != sizeof(WIN_CERTIFICATE)) + if (n != sizeof(WIN_CERTIFICATE_HEADER)) return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short write while writing certificate header."); end += n;