]> git.proxmox.com Git - efi-boot-shim.git/blob - debian/patches/fix-32b-format-strings.patch
Update upstream source from tag 'upstream/15.6'
[efi-boot-shim.git] / debian / patches / fix-32b-format-strings.patch
1 PR submitted at https://github.com/rhboot/shim/pull/464
2
3 commit 475d5293608dd64955bc76dd6eb0f379b0c37b3e
4 Author: Steve McIntyre <steve@einval.com>
5 Date: Thu Apr 28 11:37:12 2022 +0100
6
7 post-process-pe: Fix format string warnings on 32-bit platforms
8
9 With -Werror these were causing build failures with stricter gcc:
10
11 .../post-process-pe.c: In function 'load_pe':
12 .../post-process-pe.c:177:55: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
13 .../post-process-pe.c:192:56: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'UINT64' {aka 'long long unsigned int'} [-Werror=format=]
14 .../post-process-pe.c:236:31: error: format '%zu' expects argument of type 'size_t', but argument 2 has type 'UINT64' {aka 'long long unsigned int'} [-Werror=format=]
15 .../post-process-pe.c:39:32: note: in definition of macro 'debug'
16 .../post-process-pe.c:236:60: note: format string is defined here
17 .../post-process-pe.c:240:31: error: format '%zu' expects argument of type 'size_t', but argument 2 has type 'UINT64' {aka 'long long unsigned int'} [-Werror=format=]
18 .../post-process-pe.c:39:32: note: in definition of macro 'debug'
19 .../post-process-pe.c:240:60: note: format string is defined here
20 .../post-process-pe.c:274:30: error: format '%zu' expects argument of type 'size_t', but argument 2 has type 'UINTN' {aka 'long unsigned int'} [-Werror=format=]
21 .../post-process-pe.c:39:32: note: in definition of macro 'debug'
22 .../post-process-pe.c:274:34: note: format string is defined here
23
24 Signed-off-by: Steve McIntyre <steve@einval.com>
25
26 diff --git a/post-process-pe.c b/post-process-pe.c
27 index 44077bc5..daacf5ef 100644
28 --- a/post-process-pe.c
29 +++ b/post-process-pe.c
30 @@ -174,7 +174,7 @@ load_pe(const char *const file, void *const data, const size_t datasize,
31 }
32
33 if (FileAlignment % 2 != 0)
34 - errx(1, "%s: Invalid file alignment %ld", file, FileAlignment);
35 + errx(1, "%s: Invalid file alignment %zu", file, FileAlignment);
36
37 if (FileAlignment == 0)
38 FileAlignment = 0x200;
39 @@ -190,7 +190,7 @@ load_pe(const char *const file, void *const data, const size_t datasize,
40 ctx->NumberOfRvaAndSizes, EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES);
41 if (EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES < ctx->NumberOfRvaAndSizes)
42 errx(1, "%s: invalid number of RVAs (%lu entries, max is %d)",
43 - file, ctx->NumberOfRvaAndSizes,
44 + file, (unsigned long)ctx->NumberOfRvaAndSizes,
45 EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES);
46
47 if (mul(sizeof(EFI_IMAGE_DATA_DIRECTORY),
48 @@ -233,12 +233,12 @@ load_pe(const char *const file, void *const data, const size_t datasize,
49 if (mul(ctx->NumberOfRvaAndSizes,
50 sizeof(EFI_IMAGE_DATA_DIRECTORY), &sz1))
51 debug(ERROR,
52 - "ctx->NumberOfRvaAndSizes (%zu) * sizeof(EFI_IMAGE_DATA_DIRECTORY) overflows\n",
53 - ctx->NumberOfRvaAndSizes);
54 + "ctx->NumberOfRvaAndSizes (%ld) * sizeof(EFI_IMAGE_DATA_DIRECTORY) overflows\n",
55 + (unsigned long)ctx->NumberOfRvaAndSizes);
56 else
57 debug(ERROR,
58 - "ctx->NumberOfRvaAndSizes (%zu) * sizeof(EFI_IMAGE_DATA_DIRECTORY) = %zu\n",
59 - ctx->NumberOfRvaAndSizes, sz1);
60 + "ctx->NumberOfRvaAndSizes (%ld) * sizeof(EFI_IMAGE_DATA_DIRECTORY) = %zu\n",
61 + (unsigned long)ctx->NumberOfRvaAndSizes, sz1);
62 debug(ERROR,
63 "space after image header:%zu data directory size:%zu\n",
64 sz0, sz1);
65 @@ -271,7 +271,7 @@ load_pe(const char *const file, void *const data, const size_t datasize,
66 if (sub(ctx->SizeOfHeaders, SectionHeaderOffset, &sz0) ||
67 div(sz0, EFI_IMAGE_SIZEOF_SECTION_HEADER, &sz0) ||
68 (sz0 < ctx->NumberOfSections)) {
69 - debug(ERROR, "(%zu - %zu) / %d >= %d\n", ctx->SizeOfHeaders,
70 + debug(ERROR, "(%zu - %zu) / %d >= %d\n", (size_t)ctx->SizeOfHeaders,
71 SectionHeaderOffset, EFI_IMAGE_SIZEOF_SECTION_HEADER,
72 ctx->NumberOfSections);
73 errx(1, "%s: image sections overflow section headers", file);