]>
Commit | Line | Data |
---|---|---|
bab38dad MT |
1 | From ddfb60813c74e988ba7c16dbbe1b163593c9da4e Mon Sep 17 00:00:00 2001 |
2 | From: Christian Hesse <mail@eworm.de> | |
3 | Date: Tue, 15 May 2018 23:25:01 +0200 | |
4 | Subject: [PATCH] [build] fix stringop truncation warning with GCC 8.x | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | GCC 8.x gives a warning about stringop truncation: | |
10 | ||
11 | util/elf2efi.c:497:2: error: ‘strncpy’ specified bound 8 equals destination | |
12 | size [-Werror=stringop-truncation] | |
13 | ||
14 | It assumes that strncpy() is intended to copy strings, which are NULL | |
15 | terminated. We do copy fixed size memory regions, so use memcpy() instead. | |
16 | --- | |
17 | src/util/elf2efi.c | 2 +- | |
18 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
19 | ||
20 | diff --git a/src/util/elf2efi.c b/src/util/elf2efi.c | |
21 | index 6718df777..de3c92463 100644 | |
22 | --- a/src/util/elf2efi.c | |
23 | +++ b/src/util/elf2efi.c | |
24 | @@ -494,7 +494,7 @@ static struct pe_section * process_section ( struct elf_file *elf, | |
25 | memset ( new, 0, sizeof ( *new ) + section_filesz ); | |
26 | ||
27 | /* Fill in section header details */ | |
28 | - strncpy ( ( char * ) new->hdr.Name, name, sizeof ( new->hdr.Name ) ); | |
29 | + memcpy ( ( char * ) new->hdr.Name, name, sizeof ( new->hdr.Name ) ); | |
30 | new->hdr.Misc.VirtualSize = section_memsz; | |
31 | new->hdr.VirtualAddress = shdr->sh_addr; | |
32 | new->hdr.SizeOfRawData = section_filesz; |