summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-extended')
-rw-r--r--meta/recipes-extended/cpio/cpio-2.12/0001-Fix-segfault-with-append.patch100
1 files changed, 32 insertions, 68 deletions
diff --git a/meta/recipes-extended/cpio/cpio-2.12/0001-Fix-segfault-with-append.patch b/meta/recipes-extended/cpio/cpio-2.12/0001-Fix-segfault-with-append.patch
index 2043c890cd..ec8b303c43 100644
--- a/meta/recipes-extended/cpio/cpio-2.12/0001-Fix-segfault-with-append.patch
+++ b/meta/recipes-extended/cpio/cpio-2.12/0001-Fix-segfault-with-append.patch
@@ -1,87 +1,51 @@
1Upstream-Status: Submitted [bugs-cpio] 1Upstream-Status: Backport
2Signed-off-by: Ross Burton <ross.burton@intel.com> 2Signed-off-by: Ross Burton <ross.burton@intel.com>
3 3
4From 3f0bd5a40ad0ceaee78c74a52a7166ed7f08db81 Mon Sep 17 00:00:00 2001 4From 32d95fe0c90c59352a0ce3102fc9866cbfb0f629 Mon Sep 17 00:00:00 2001
5From: Pavel Raiskup <praiskup@redhat.com> 5From: Sergey Poznyakoff <gray@gnu.org>
6Date: Thu, 29 Nov 2018 07:03:48 +0100 6Date: Sat, 1 Dec 2018 11:40:02 +0200
7Subject: [PATCH] Fix segfault with --append 7Subject: [PATCH] Fix sigfault when appending to archive
8 8
9The --append mode combines both process_copy_in() and 9Bug reported by Ross Burton. See
10process_copy_out() methods, each of them working with different 10<http://lists.gnu.org/archive/html/bug-cpio/2018-11/msg00000.html>
11(local) file_hdr->c_name buffers. So ensure that
12cpio_set_c_name() isn't using the same static variable for
13maintaining length of different buffers.
14 11
15Complements d36ec5f4e93130efb24fb9. Thanks to Ross Burton. 12* src/util.c: Keep static copy of the buffer pointer; always
16 13assign it to file_hdr->c_name. Use x2realloc for memory management.
17* src/copyin.c (process_copy_in): Always initialize file_hdr.
18* src/copyout.c (process_copy_out): Likewise.
19* src/cpiohdr.h (cpio_file_stat): Add c_name_buflen variable.
20* src/util.c (cpio_set_c_name): Use file_hdr->c_name_buflen.
21--- 14---
22 src/copyin.c | 1 + 15 src/util.c | 17 ++++-------------
23 src/copyout.c | 1 + 16 1 file changed, 4 insertions(+), 13 deletions(-)
24 src/cpiohdr.h | 1 +
25 src/util.c | 3 ++-
26 4 files changed, 5 insertions(+), 1 deletion(-)
27 17
28diff --git a/src/copyin.c b/src/copyin.c
29index ba887ae..767c2f8 100644
30--- a/src/copyin.c
31+++ b/src/copyin.c
32@@ -1213,6 +1213,7 @@ process_copy_in ()
33
34 newdir_umask = umask (0); /* Reset umask to preserve modes of
35 created files */
36+ memset (&file_hdr, 0, sizeof (struct cpio_file_stat));
37
38 /* Initialize the copy in. */
39 if (pattern_file_name)
40diff --git a/src/copyout.c b/src/copyout.c
41index 7532dac..fb890cb 100644
42--- a/src/copyout.c
43+++ b/src/copyout.c
44@@ -594,6 +594,7 @@ process_copy_out ()
45
46 /* Initialize the copy out. */
47 ds_init (&input_name, 128);
48+ memset (&file_hdr, 0, sizeof (struct cpio_file_stat));
49 file_hdr.c_magic = 070707;
50
51 /* Check whether the output file might be a tape. */
52diff --git a/src/cpiohdr.h b/src/cpiohdr.h
53index 588135b..cf64f3e 100644
54--- a/src/cpiohdr.h
55+++ b/src/cpiohdr.h
56@@ -127,6 +127,7 @@ struct cpio_file_stat /* Internal representation of a CPIO header */
57 uint32_t c_chksum;
58 char *c_name;
59 char *c_tar_linkname;
60+ size_t c_name_buflen;
61 };
62
63 void cpio_set_c_name(struct cpio_file_stat *file_hdr, char *name);
64diff --git a/src/util.c b/src/util.c 18diff --git a/src/util.c b/src/util.c
65index 10486dc..1256469 100644 19index 10486dc..4e49124 100644
66--- a/src/util.c 20--- a/src/util.c
67+++ b/src/util.c 21+++ b/src/util.c
68@@ -1413,7 +1413,7 @@ set_file_times (int fd, 22@@ -1413,22 +1413,13 @@ set_file_times (int fd,
69 void 23 void
70 cpio_set_c_name (struct cpio_file_stat *file_hdr, char *name) 24 cpio_set_c_name (struct cpio_file_stat *file_hdr, char *name)
71 { 25 {
72- static size_t buflen = 0; 26+ static char *buf = NULL;
73+ size_t buflen = file_hdr->c_name_buflen; 27 static size_t buflen = 0;
74 size_t len = strlen (name) + 1; 28 size_t len = strlen (name) + 1;
75 29
76 if (buflen == 0) 30- if (buflen == 0)
77@@ -1430,6 +1430,7 @@ cpio_set_c_name (struct cpio_file_stat *file_hdr, char *name) 31- {
78 } 32- buflen = len;
79 33- if (buflen < 32)
34- buflen = 32;
35- file_hdr->c_name = xmalloc (buflen);
36- }
37- else if (buflen < len)
38- {
39- buflen = len;
40- file_hdr->c_name = xrealloc (file_hdr->c_name, buflen);
41- }
42-
43+ while (buflen < len)
44+ buf = x2realloc (buf, &buflen);
45+ file_hdr->c_name = buf;
80 file_hdr->c_namesize = len; 46 file_hdr->c_namesize = len;
81+ file_hdr->c_name_buflen = buflen;
82 memmove (file_hdr->c_name, name, len); 47 memmove (file_hdr->c_name, name, len);
83 } 48 }
84
85-- 49--
862.11.0 502.18.0
87 51