summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/ovmf/ovmf/0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/ovmf/ovmf/0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch')
-rw-r--r--meta/recipes-core/ovmf/ovmf/0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch66
1 files changed, 66 insertions, 0 deletions
diff --git a/meta/recipes-core/ovmf/ovmf/0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch b/meta/recipes-core/ovmf/ovmf/0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch
new file mode 100644
index 0000000000..7ad7cdf0ce
--- /dev/null
+++ b/meta/recipes-core/ovmf/ovmf/0004-BaseTools-GenVtf-silence-false-stringop-overflow-war.patch
@@ -0,0 +1,66 @@
1From dfb42a5bff78d9239a80731e337855234badef3e Mon Sep 17 00:00:00 2001
2From: Laszlo Ersek <lersek@redhat.com>
3Date: Fri, 2 Mar 2018 17:11:52 +0100
4Subject: [PATCH 4/4] BaseTools/GenVtf: silence false "stringop-overflow"
5 warning with memcpy()
6
7gcc-8 (which is part of Fedora 28) enables the new warning
8"-Wstringop-overflow" in "-Wall". This warning is documented in detail at
9<https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>; the
10introduction says
11
12> Warn for calls to string manipulation functions such as memcpy and
13> strcpy that are determined to overflow the destination buffer.
14
15It breaks the BaseTools build with:
16
17> GenVtf.c: In function 'ConvertVersionInfo':
18> GenVtf.c:132:7: error: 'strncpy' specified bound depends on the length
19> of the source argument [-Werror=stringop-overflow=]
20> strncpy (TemStr + 4 - Length, Str, Length);
21> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22> GenVtf.c:130:14: note: length computed here
23> Length = strlen(Str);
24> ^~~~~~~~~~~
25
26It is a false positive because, while the bound equals the length of the
27source argument, the destination pointer is moved back towards the
28beginning of the destination buffer by the same amount (and this amount is
29range-checked first, so we can't precede the start of the dest buffer).
30
31Replace both strncpy() calls with memcpy().
32
33Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
34Cc: Cole Robinson <crobinso@redhat.com>
35Cc: Liming Gao <liming.gao@intel.com>
36Cc: Paolo Bonzini <pbonzini@redhat.com>
37Cc: Yonghong Zhu <yonghong.zhu@intel.com>
38Reported-by: Cole Robinson <crobinso@redhat.com>
39Contributed-under: TianoCore Contribution Agreement 1.1
40Signed-off-by: Laszlo Ersek <lersek@redhat.com>
41Reviewed-by: Liming Gao <liming.gao@intel.com>
42---
43Signed-off-by: Khem Raj <raj.khem@gmail.com>
44Upstream-Status: Backport
45 BaseTools/Source/C/GenVtf/GenVtf.c | 4 ++--
46 1 file changed, 2 insertions(+), 2 deletions(-)
47
48diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c
49index 2ae9a7be2c..0cd33e71e9 100644
50--- a/BaseTools/Source/C/GenVtf/GenVtf.c
51+++ b/BaseTools/Source/C/GenVtf/GenVtf.c
52@@ -129,9 +129,9 @@ Returns:
53 } else {
54 Length = strlen(Str);
55 if (Length < 4) {
56- strncpy (TemStr + 4 - Length, Str, Length);
57+ memcpy (TemStr + 4 - Length, Str, Length);
58 } else {
59- strncpy (TemStr, Str + Length - 4, 4);
60+ memcpy (TemStr, Str + Length - 4, 4);
61 }
62
63 sscanf (
64--
652.17.0
66