diff options
author | Roy Li <rongqing.li@windriver.com> | 2014-10-15 17:21:34 +0800 |
---|---|---|
committer | Andreas Oberritter <obi@opendreambox.org> | 2015-10-12 15:11:54 +0200 |
commit | 4c8c9a5d1c6c6711f953b5cab01861e1343e0cbd (patch) | |
tree | 144ea4e6fbdcdb5a7a59c48c18dbbc36704a3132 | |
parent | 06e1d906102bc34f3b200b059b926916c4ff6fee (diff) | |
download | openembedded-core-contrib-4c8c9a5d1c6c6711f953b5cab01861e1343e0cbd.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
Signed-off-by: Roy Li <rongqing.li@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
(cherry picked from commit af56e7559d31cb9cb84b85a7dedd8e12cf1f06cd)
Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
-rw-r--r-- | meta/recipes-connectivity/nfs-utils/files/fix-a-Gcc-undefined-behavior.patch | 38 | ||||
-rw-r--r-- | meta/recipes-connectivity/nfs-utils/nfs-utils_1.3.0.bb | 1 |
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 @@ +[PATCH] fix a Gcc undefined behavior + +Upstream-Status: Pending + +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 + +Signed-off-by: Roy Li <rongqing.li@windriver.com> +--- + support/export/client.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/support/export/client.c b/support/export/client.c +index dbf47b9..a37ef69 100644 +--- a/support/export/client.c ++++ b/support/export/client.c +@@ -482,8 +482,13 @@ add_name(char *old, const char *add) + else + cp = cp + strlen(cp); + } +- strncpy(new, old, cp-old); +- new[cp-old] = 0; ++ ++ if (old) { ++ strncpy(new, old, cp-old); ++ new[cp-old] = 0; ++ } else ++ new[0] = 0; ++ + if (cp != old && !*cp) + strcat(new, ","); + strcat(new, add); +-- +1.7.10.4 + 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 c3c6d0b7b4..e41d5a87a4 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 @@ -32,6 +32,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.x file://nfs-statd.service \ file://nfs-utils-Do-not-pass-CFLAGS-to-gcc-while-building.patch \ file://0001-statd-fixed-the-with-statdpath-flag.patch \ + file://fix-a-Gcc-undefined-behavior.patch \ " SRC_URI[md5sum] = "6e93a7997ca3a1eac56bf219adab72a8" |