summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Li <rongqing.li@windriver.com>2014-10-15 17:21:34 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-10-24 17:36:14 +0100
commit5269dfa0e61025bae0b059d7f188afec249e7baf (patch)
treea48c3b2971e1088ad12157d6dc66977bd0da95ef
parentd7cb96f28ddab87653d4cc03ea1b478c4efac616 (diff)
downloadpoky-5269dfa0e61025bae0b059d7f188afec249e7baf.tar.gz
nfs-utils: fix a Gcc undefined behavior
Calling strncpy with NULL second argument, even when the size is 0, is undefined behavior, which leads to GCC to drop the check old variable with NULL in following code. https://bugzilla.yoctoproject.org/show_bug.cgi?id=6743 (From OE-Core rev: af56e7559d31cb9cb84b85a7dedd8e12cf1f06cd) Signed-off-by: Roy Li <rongqing.li@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-connectivity/nfs-utils/files/fix-a-Gcc-undefined-behavior.patch38
-rw-r--r--meta/recipes-connectivity/nfs-utils/nfs-utils_1.3.0.bb1
2 files changed, 39 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/nfs-utils/files/fix-a-Gcc-undefined-behavior.patch b/meta/recipes-connectivity/nfs-utils/files/fix-a-Gcc-undefined-behavior.patch
new file mode 100644
index 0000000000..5843ba0fb9
--- /dev/null
+++ b/meta/recipes-connectivity/nfs-utils/files/fix-a-Gcc-undefined-behavior.patch
@@ -0,0 +1,38 @@
1[PATCH] fix a Gcc undefined behavior
2
3Upstream-Status: Pending
4
5Calling strncpy with NULL second argument, even when the size is 0,
6is undefined behavior, which leads to GCC to drop the check old
7variable with NULL in following code.
8
9https://bugzilla.yoctoproject.org/show_bug.cgi?id=6743
10
11Signed-off-by: Roy Li <rongqing.li@windriver.com>
12---
13 support/export/client.c | 9 +++++++--
14 1 file changed, 7 insertions(+), 2 deletions(-)
15
16diff --git a/support/export/client.c b/support/export/client.c
17index dbf47b9..a37ef69 100644
18--- a/support/export/client.c
19+++ b/support/export/client.c
20@@ -482,8 +482,13 @@ add_name(char *old, const char *add)
21 else
22 cp = cp + strlen(cp);
23 }
24- strncpy(new, old, cp-old);
25- new[cp-old] = 0;
26+
27+ if (old) {
28+ strncpy(new, old, cp-old);
29+ new[cp-old] = 0;
30+ } else
31+ new[0] = 0;
32+
33 if (cp != old && !*cp)
34 strcat(new, ",");
35 strcat(new, add);
36--
371.7.10.4
38
diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils_1.3.0.bb b/meta/recipes-connectivity/nfs-utils/nfs-utils_1.3.0.bb
index c813d7f61e..f1ef6d9a0c 100644
--- a/meta/recipes-connectivity/nfs-utils/nfs-utils_1.3.0.bb
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils_1.3.0.bb
@@ -31,6 +31,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x
31 file://nfs-statd.service \ 31 file://nfs-statd.service \
32 file://nfs-utils-Do-not-pass-CFLAGS-to-gcc-while-building.patch \ 32 file://nfs-utils-Do-not-pass-CFLAGS-to-gcc-while-building.patch \
33 file://0001-statd-fixed-the-with-statdpath-flag.patch \ 33 file://0001-statd-fixed-the-with-statdpath-flag.patch \
34 file://fix-a-Gcc-undefined-behavior.patch \
34" 35"
35 36
36SRC_URI[md5sum] = "6e93a7997ca3a1eac56bf219adab72a8" 37SRC_URI[md5sum] = "6e93a7997ca3a1eac56bf219adab72a8"