* [PATCH] nfs-utils: fix a Gcc undefined behavior
@ 2014-10-15 9:21 rongqing.li
2014-10-20 3:22 ` Rongqing Li
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: rongqing.li @ 2014-10-15 9:21 UTC (permalink / raw)
To: openembedded-core
From: Roy Li <rongqing.li@windriver.com>
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>
---
.../files/fix-a-Gcc-undefined-behavior.patch | 38 ++++++++++++++++++++
.../nfs-utils/nfs-utils_1.3.0.bb | 1 +
2 files changed, 39 insertions(+)
create mode 100644 meta/recipes-connectivity/nfs-utils/files/fix-a-Gcc-undefined-behavior.patch
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 0000000..5843ba0
--- /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 c813d7f..f1ef6d9 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
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"
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] nfs-utils: fix a Gcc undefined behavior
2014-10-15 9:21 [PATCH] nfs-utils: fix a Gcc undefined behavior rongqing.li
@ 2014-10-20 3:22 ` Rongqing Li
2014-10-20 3:39 ` Khem Raj
2014-10-20 10:59 ` Burton, Ross
2 siblings, 0 replies; 5+ messages in thread
From: Rongqing Li @ 2014-10-20 3:22 UTC (permalink / raw)
To: rongqing.li; +Cc: openembedded-core
ping
-R
On 10/15/2014 05:21 PM, rongqing.li@windriver.com wrote:
> From: Roy Li <rongqing.li@windriver.com>
>
> 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>
> ---
> .../files/fix-a-Gcc-undefined-behavior.patch | 38 ++++++++++++++++++++
> .../nfs-utils/nfs-utils_1.3.0.bb | 1 +
> 2 files changed, 39 insertions(+)
> create mode 100644 meta/recipes-connectivity/nfs-utils/files/fix-a-Gcc-undefined-behavior.patch
>
> 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 0000000..5843ba0
> --- /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 c813d7f..f1ef6d9 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
> 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"
>
--
Best Reagrds,
Roy | RongQing Li
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] nfs-utils: fix a Gcc undefined behavior
2014-10-15 9:21 [PATCH] nfs-utils: fix a Gcc undefined behavior rongqing.li
2014-10-20 3:22 ` Rongqing Li
@ 2014-10-20 3:39 ` Khem Raj
2014-10-20 10:59 ` Burton, Ross
2 siblings, 0 replies; 5+ messages in thread
From: Khem Raj @ 2014-10-20 3:39 UTC (permalink / raw)
To: rongqing.li@windriver.com; +Cc: Patches and discussions about the oe-core layer
On Wed, Oct 15, 2014 at 2:21 AM, <rongqing.li@windriver.com> wrote:
> From: Roy Li <rongqing.li@windriver.com>
>
> 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
FWIW this is correct way to fix it
>
> Signed-off-by: Roy Li <rongqing.li@windriver.com>
> ---
> .../files/fix-a-Gcc-undefined-behavior.patch | 38 ++++++++++++++++++++
> .../nfs-utils/nfs-utils_1.3.0.bb | 1 +
> 2 files changed, 39 insertions(+)
> create mode 100644 meta/recipes-connectivity/nfs-utils/files/fix-a-Gcc-undefined-behavior.patch
>
> 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 0000000..5843ba0
> --- /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 c813d7f..f1ef6d9 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
> 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"
> --
> 1.7.10.4
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] nfs-utils: fix a Gcc undefined behavior
2014-10-15 9:21 [PATCH] nfs-utils: fix a Gcc undefined behavior rongqing.li
2014-10-20 3:22 ` Rongqing Li
2014-10-20 3:39 ` Khem Raj
@ 2014-10-20 10:59 ` Burton, Ross
2014-10-21 0:10 ` Rongqing Li
2 siblings, 1 reply; 5+ messages in thread
From: Burton, Ross @ 2014-10-20 10:59 UTC (permalink / raw)
To: rongqing.li@windriver.com; +Cc: OE-core
On 15 October 2014 10:21, <rongqing.li@windriver.com> wrote:
> 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
I've merged this into my MUT branch but we're very late for 1.7.0
unless it's a critical fix. We can roll this into 1.7.1 though.
Ross
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nfs-utils: fix a Gcc undefined behavior
2014-10-20 10:59 ` Burton, Ross
@ 2014-10-21 0:10 ` Rongqing Li
0 siblings, 0 replies; 5+ messages in thread
From: Rongqing Li @ 2014-10-21 0:10 UTC (permalink / raw)
To: Burton, Ross; +Cc: OE-core
On 10/20/2014 06:59 PM, Burton, Ross wrote:
> On 15 October 2014 10:21, <rongqing.li@windriver.com> wrote:
>> 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
>
> I've merged this into my MUT branch but we're very late for 1.7.0
> unless it's a critical fix. We can roll this into 1.7.1 though.
>
> Ross
>
It make the nfs-server unable to start up on my test environment
-Roy
--
Best Reagrds,
Roy | RongQing Li
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-10-21 0:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-15 9:21 [PATCH] nfs-utils: fix a Gcc undefined behavior rongqing.li
2014-10-20 3:22 ` Rongqing Li
2014-10-20 3:39 ` Khem Raj
2014-10-20 10:59 ` Burton, Ross
2014-10-21 0:10 ` Rongqing Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox