From 791bb999eef6da39d2160701f7d308e86113eefd Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Fri, 15 Jan 2016 17:17:43 +0100 Subject: initial commit for Enea Linux 5.0-ppc Signed-off-by: Adrian Dudau --- .../nfs-utils/fix-segfault-in-add_name.patch | 59 ++++++++++++++++++++++ .../nfs-utils/nfs-utils_1.3.0.bb | 1 + 2 files changed, 60 insertions(+) create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/fix-segfault-in-add_name.patch (limited to 'meta/recipes-connectivity/nfs-utils') diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/fix-segfault-in-add_name.patch b/meta/recipes-connectivity/nfs-utils/nfs-utils/fix-segfault-in-add_name.patch new file mode 100644 index 0000000000..4ebf2dcee4 --- /dev/null +++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/fix-segfault-in-add_name.patch @@ -0,0 +1,59 @@ +commit 25e83c2270b2d2966c992885faed0b79be09f474 +Author: Jeff Layton +Date: Thu May 1 11:15:16 2014 -0400 + + mountd: fix segfault in add_name with newer gcc compilers + + I hit a segfault in add_name with a mountd built with gcc-4.9.0. Some + NULL pointer checks got reordered such that a pointer was dereferenced + before checking to see whether it was NULL. The problem was due to + nfs-utils relying on undefined behavior, which tricked gcc into assuming + that the pointer would never be NULL. + + At first I assumed that this was a compiler bug, but Jakub Jelinek and + Jeff Law pointed out: + + "If old is NULL, then: + + strncpy(new, old, cp-old); + + is undefined behavior (even when cp == old == NULL in that case), + therefore gcc assumes that old is never NULL, as otherwise it would be + invalid. + + Just guard + strncpy(new, old, cp-old); + new[cp-old] = 0; + with if (old) { ... }." + + This patch does that. If old is NULL though, then we still need to + ensure that new is NULL terminated, lest the subsequent strcats walk off + the end of it. + + Cc: Jeff Law + Cc: Jakub Jelinek + Signed-off-by: Jeff Layton + Signed-off-by: Steve Dickson + + Upstream-Status:Backport + Signed-off-by: Tudor Florea + +diff --git a/support/export/client.c b/support/export/client.c +index dbf47b9..f85e11c 100644 +--- a/support/export/client.c ++++ b/support/export/client.c +@@ -482,8 +482,12 @@ 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); 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 6e6d09bf42..dcdb35e51c 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-segfault-in-add_name.patch \ " SRC_URI[md5sum] = "6e93a7997ca3a1eac56bf219adab72a8" -- cgit v1.2.3-54-g00ecf