]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sbsign: rename WIN_CERTIFICATE -> WIN_CERTIFICATE_HEADER and drop trailing flexible...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 3 Apr 2025 16:15:19 +0000 (01:15 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 4 Apr 2025 11:54:53 +0000 (20:54 +0900)
To allow building sbsign with -Werror=flex-array-member-not-at-end.

src/fundamental/efi-fundamental.h
src/sbsign/sbsign.c

index de7ae6cd8a4341d5922aef83db98b77f9305c6d3..f72290e1b3f050ab677d24a5612c55add228f8eb 100644 (file)
@@ -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;
index b2f0d861ce136c55eb5b76496e0a6b94b3a04d3d..74e05d4b40006e74f5a6f5302558d37a99328a4d 100644 (file)
@@ -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;