mountd: fix segfault in add_name with newer gcc compilers
Signed-off-by: Steve Dickson <steved@redhat.com>
This commit is contained in:
parent
2abd2dd759
commit
cd0d5ea2a7
61
nfs-utils-1.3.0-mound-newgcc.patch
Normal file
61
nfs-utils-1.3.0-mound-newgcc.patch
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
From 25e83c2270b2d2966c992885faed0b79be09f474 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jeff Layton <jlayton@poochiereds.net>
|
||||||
|
Date: Thu, 1 May 2014 11:15:16 -0400
|
||||||
|
Subject: [PATCH] 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 <law@redhat.com>
|
||||||
|
Cc: Jakub Jelinek <jakub@redhat.com>
|
||||||
|
Signed-off-by: Jeff Layton <jlayton@poochiereds.net>
|
||||||
|
Signed-off-by: Steve Dickson <steved@redhat.com>
|
||||||
|
---
|
||||||
|
support/export/client.c | 8 ++++++--
|
||||||
|
1 file changed, 6 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
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);
|
||||||
|
--
|
||||||
|
1.9.0
|
||||||
|
|
@ -2,7 +2,7 @@ Summary: NFS utilities and supporting clients and daemons for the kernel NFS ser
|
|||||||
Name: nfs-utils
|
Name: nfs-utils
|
||||||
URL: http://sourceforge.net/projects/nfs
|
URL: http://sourceforge.net/projects/nfs
|
||||||
Version: 1.3.0
|
Version: 1.3.0
|
||||||
Release: 1.1%{?dist}
|
Release: 1.2%{?dist}
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
|
|
||||||
# group all 32bit related archs
|
# group all 32bit related archs
|
||||||
@ -16,6 +16,7 @@ Source3: nfs-utils_env.sh
|
|||||||
|
|
||||||
Patch001: nfs-utils-1.3.1-rc1.patch
|
Patch001: nfs-utils-1.3.1-rc1.patch
|
||||||
Patch002: nfs-utils-1.3.0-start-statd.patch
|
Patch002: nfs-utils-1.3.0-start-statd.patch
|
||||||
|
Patch003: nfs-utils-1.3.0-mound-newgcc.patch
|
||||||
|
|
||||||
Patch100: nfs-utils-1.2.1-statdpath-man.patch
|
Patch100: nfs-utils-1.2.1-statdpath-man.patch
|
||||||
Patch101: nfs-utils-1.2.1-exp-subtree-warn-off.patch
|
Patch101: nfs-utils-1.2.1-exp-subtree-warn-off.patch
|
||||||
@ -75,6 +76,7 @@ This package also contains the mount.nfs and umount.nfs program.
|
|||||||
|
|
||||||
%patch001 -p1
|
%patch001 -p1
|
||||||
%patch002 -p1
|
%patch002 -p1
|
||||||
|
%patch003 -p1
|
||||||
|
|
||||||
%patch100 -p1
|
%patch100 -p1
|
||||||
%patch101 -p1
|
%patch101 -p1
|
||||||
@ -283,6 +285,9 @@ fi
|
|||||||
/sbin/umount.nfs4
|
/sbin/umount.nfs4
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu May 1 2014 Steve Dickson <steved@redhat.com> 1.3.0-1.2
|
||||||
|
- mountd: fix segfault in add_name with newer gcc compilers
|
||||||
|
|
||||||
* Thu May 1 2014 Steve Dickson <steved@redhat.com> 1.3.0-1.1
|
* Thu May 1 2014 Steve Dickson <steved@redhat.com> 1.3.0-1.1
|
||||||
- start-statd: rpc.statd's systemd unit changed names
|
- start-statd: rpc.statd's systemd unit changed names
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user