Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in net-fs/nfs-utils/files: nfs-utils-1.3.0-gcc-4.9.patch
Date: Fri, 20 Jun 2014 06:24:31
Message-Id: 20140620062427.5CE5B2004E@flycatcher.gentoo.org
1 vapier 14/06/20 06:24:27
2
3 Added: nfs-utils-1.3.0-gcc-4.9.patch
4 Log:
5 Version bump #506760 by Nenad Peric. Run keepdir on /etc/exports.d #470102 by Alon Bar-Lev.
6
7 (Portage version: 2.2.10/cvs/Linux x86_64, signed Manifest commit with key D2E96200)
8
9 Revision Changes Path
10 1.1 net-fs/nfs-utils/files/nfs-utils-1.3.0-gcc-4.9.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-fs/nfs-utils/files/nfs-utils-1.3.0-gcc-4.9.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-fs/nfs-utils/files/nfs-utils-1.3.0-gcc-4.9.patch?rev=1.1&content-type=text/plain
14
15 Index: nfs-utils-1.3.0-gcc-4.9.patch
16 ===================================================================
17 From 25e83c2270b2d2966c992885faed0b79be09f474 Mon Sep 17 00:00:00 2001
18 From: Jeff Layton <jlayton@×××××××××××.net>
19 Date: Thu, 1 May 2014 11:15:16 -0400
20 Subject: [PATCH [nfs-utils]] mountd: fix segfault in add_name with newer gcc
21 compilers
22
23 I hit a segfault in add_name with a mountd built with gcc-4.9.0. Some
24 NULL pointer checks got reordered such that a pointer was dereferenced
25 before checking to see whether it was NULL. The problem was due to
26 nfs-utils relying on undefined behavior, which tricked gcc into assuming
27 that the pointer would never be NULL.
28
29 At first I assumed that this was a compiler bug, but Jakub Jelinek and
30 Jeff Law pointed out:
31
32 "If old is NULL, then:
33
34 strncpy(new, old, cp-old);
35
36 is undefined behavior (even when cp == old == NULL in that case),
37 therefore gcc assumes that old is never NULL, as otherwise it would be
38 invalid.
39
40 Just guard
41 strncpy(new, old, cp-old);
42 new[cp-old] = 0;
43 with if (old) { ... }."
44
45 This patch does that. If old is NULL though, then we still need to
46 ensure that new is NULL terminated, lest the subsequent strcats walk off
47 the end of it.
48
49 Cc: Jeff Law <law@××××××.com>
50 Cc: Jakub Jelinek <jakub@××××××.com>
51 Signed-off-by: Jeff Layton <jlayton@×××××××××××.net>
52 Signed-off-by: Steve Dickson <steved@××××××.com>
53 ---
54 support/export/client.c | 8 ++++++--
55 1 file changed, 6 insertions(+), 2 deletions(-)
56
57 diff --git a/support/export/client.c b/support/export/client.c
58 index dbf47b9..f85e11c 100644
59 --- a/support/export/client.c
60 +++ b/support/export/client.c
61 @@ -482,8 +482,12 @@ add_name(char *old, const char *add)
62 else
63 cp = cp + strlen(cp);
64 }
65 - strncpy(new, old, cp-old);
66 - new[cp-old] = 0;
67 + if (old) {
68 + strncpy(new, old, cp-old);
69 + new[cp-old] = 0;
70 + } else {
71 + new[0] = 0;
72 + }
73 if (cp != old && !*cp)
74 strcat(new, ",");
75 strcat(new, add);
76 --
77 2.0.0