diff options
| author | Tudor Florea <tudor.florea@enea.com> | 2015-12-10 23:28:17 +0100 |
|---|---|---|
| committer | Adrian Calianu <adrian.calianu@enea.com> | 2015-12-14 13:51:12 +0100 |
| commit | 218c2f039ccf435e42716ba1208a1ecbdb8f653c (patch) | |
| tree | 7edd5400b6f259b23e8dd0d7926f3270303276a3 | |
| parent | 406ec45b2045b63a73719b1203f3418bace0d122 (diff) | |
| download | meta-el-common-218c2f039ccf435e42716ba1208a1ecbdb8f653c.tar.gz | |
nfs-utils: fix for segfault in add_name
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Signed-off-by: Adrian Calianu <adrian.calianu@enea.com>
| -rw-r--r-- | recipes-connectivity/nfs-utils/nfs-utils/fix-segfault-in-add_name.patch | 59 | ||||
| -rw-r--r-- | recipes-connectivity/nfs-utils/nfs-utils_1.3.0.bbappend | 5 |
2 files changed, 64 insertions, 0 deletions
diff --git a/recipes-connectivity/nfs-utils/nfs-utils/fix-segfault-in-add_name.patch b/recipes-connectivity/nfs-utils/nfs-utils/fix-segfault-in-add_name.patch new file mode 100644 index 0000000..4ebf2dc --- /dev/null +++ b/recipes-connectivity/nfs-utils/nfs-utils/fix-segfault-in-add_name.patch | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | commit 25e83c2270b2d2966c992885faed0b79be09f474 | ||
| 2 | Author: Jeff Layton <jlayton@poochiereds.net> | ||
| 3 | Date: Thu May 1 11:15:16 2014 -0400 | ||
| 4 | |||
| 5 | mountd: fix segfault in add_name with newer gcc compilers | ||
| 6 | |||
| 7 | I hit a segfault in add_name with a mountd built with gcc-4.9.0. Some | ||
| 8 | NULL pointer checks got reordered such that a pointer was dereferenced | ||
| 9 | before checking to see whether it was NULL. The problem was due to | ||
| 10 | nfs-utils relying on undefined behavior, which tricked gcc into assuming | ||
| 11 | that the pointer would never be NULL. | ||
| 12 | |||
| 13 | At first I assumed that this was a compiler bug, but Jakub Jelinek and | ||
| 14 | Jeff Law pointed out: | ||
| 15 | |||
| 16 | "If old is NULL, then: | ||
| 17 | |||
| 18 | strncpy(new, old, cp-old); | ||
| 19 | |||
| 20 | is undefined behavior (even when cp == old == NULL in that case), | ||
| 21 | therefore gcc assumes that old is never NULL, as otherwise it would be | ||
| 22 | invalid. | ||
| 23 | |||
| 24 | Just guard | ||
| 25 | strncpy(new, old, cp-old); | ||
| 26 | new[cp-old] = 0; | ||
| 27 | with if (old) { ... }." | ||
| 28 | |||
| 29 | This patch does that. If old is NULL though, then we still need to | ||
| 30 | ensure that new is NULL terminated, lest the subsequent strcats walk off | ||
| 31 | the end of it. | ||
| 32 | |||
| 33 | Cc: Jeff Law <law@redhat.com> | ||
| 34 | Cc: Jakub Jelinek <jakub@redhat.com> | ||
| 35 | Signed-off-by: Jeff Layton <jlayton@poochiereds.net> | ||
| 36 | Signed-off-by: Steve Dickson <steved@redhat.com> | ||
| 37 | |||
| 38 | Upstream-Status:Backport | ||
| 39 | Signed-off-by: Tudor Florea <tudor.florea@enea.com> | ||
| 40 | |||
| 41 | diff --git a/support/export/client.c b/support/export/client.c | ||
| 42 | index dbf47b9..f85e11c 100644 | ||
| 43 | --- a/support/export/client.c | ||
| 44 | +++ b/support/export/client.c | ||
| 45 | @@ -482,8 +482,12 @@ add_name(char *old, const char *add) | ||
| 46 | else | ||
| 47 | cp = cp + strlen(cp); | ||
| 48 | } | ||
| 49 | - strncpy(new, old, cp-old); | ||
| 50 | - new[cp-old] = 0; | ||
| 51 | + if (old) { | ||
| 52 | + strncpy(new, old, cp-old); | ||
| 53 | + new[cp-old] = 0; | ||
| 54 | + } else { | ||
| 55 | + new[0] = 0; | ||
| 56 | + } | ||
| 57 | if (cp != old && !*cp) | ||
| 58 | strcat(new, ","); | ||
| 59 | strcat(new, add); | ||
diff --git a/recipes-connectivity/nfs-utils/nfs-utils_1.3.0.bbappend b/recipes-connectivity/nfs-utils/nfs-utils_1.3.0.bbappend new file mode 100644 index 0000000..7c9faf0 --- /dev/null +++ b/recipes-connectivity/nfs-utils/nfs-utils_1.3.0.bbappend | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | ||
| 2 | |||
| 3 | SRC_URI += " \ | ||
| 4 | file://fix-segfault-in-add_name.patch \ | ||
| 5 | " | ||
