summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/cpio
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2023-05-10 18:00:34 +0100
committerSteve Sakoman <steve@sakoman.com>2023-05-17 04:07:13 -1000
commit5d50cbf525476caab190d005ac130bb5fff2ade7 (patch)
tree260c58da3989ac316d9787d24dcf0600df7bffa8 /meta/recipes-extended/cpio
parentd8c4df476ecb57dd957ba9b774371275e5aa1309 (diff)
downloadpoky-5d50cbf525476caab190d005ac130bb5fff2ade7.tar.gz
cpio: fix appending to archives larger than 2GB
Backport a patch to fix appending to archives larger than 2GB. [ YOCTO #11674 ] (From OE-Core rev: a161d6694b295c93244d67d69d8be8b09210bc32) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-extended/cpio')
-rw-r--r--meta/recipes-extended/cpio/cpio-2.13/0001-Fix-appending-to-archives-bigger-than-2G.patch312
-rw-r--r--meta/recipes-extended/cpio/cpio_2.13.bb1
2 files changed, 313 insertions, 0 deletions
diff --git a/meta/recipes-extended/cpio/cpio-2.13/0001-Fix-appending-to-archives-bigger-than-2G.patch b/meta/recipes-extended/cpio/cpio-2.13/0001-Fix-appending-to-archives-bigger-than-2G.patch
new file mode 100644
index 0000000000..fefd5b2894
--- /dev/null
+++ b/meta/recipes-extended/cpio/cpio-2.13/0001-Fix-appending-to-archives-bigger-than-2G.patch
@@ -0,0 +1,312 @@
1From 0987d63384f0419b4b14aecdc6a61729b75ce86a Mon Sep 17 00:00:00 2001
2From: Sergey Poznyakoff <gray@gnu.org>
3Date: Fri, 28 Apr 2023 15:23:46 +0300
4Subject: [PATCH] Fix appending to archives bigger than 2G
5
6* src/extern.h (last_header_start): Change type to off_t.
7* src/global.c: Likewise.
8* src/util.c (prepare_append): Use off_t for file offsets.
9
10Upstream-Status: Backport
11Signed-off-by: Ross Burton <ross.burton@arm.com>
12---
13 src/extern.h | 11 ++++-----
14 src/global.c | 2 +-
15 src/util.c | 66 ++++++++++++++++++++++++++--------------------------
16 3 files changed, 39 insertions(+), 40 deletions(-)
17
18diff --git a/src/extern.h b/src/extern.h
19index df7d0ce..6afbdd2 100644
20--- a/src/extern.h
21+++ b/src/extern.h
22@@ -68,7 +68,7 @@ extern int ignore_dirnlink_option;
23
24 extern bool to_stdout_option;
25
26-extern int last_header_start;
27+extern off_t last_header_start;
28 extern int copy_matching_files;
29 extern int numeric_uid;
30 extern char *pattern_file_name;
31@@ -128,7 +128,7 @@ void field_width_error (const char *filename, const char *fieldname,
32
33 /* copypass.c */
34 void process_copy_pass (void);
35-int link_to_maj_min_ino (char *file_name, int st_dev_maj,
36+int link_to_maj_min_ino (char *file_name, int st_dev_maj,
37 int st_dev_min, ino_t st_ino);
38 int link_to_name (char const *link_name, char const *link_target);
39
40@@ -176,7 +176,7 @@ void copy_files_tape_to_disk (int in_des, int out_des, off_t num_bytes);
41 void copy_files_disk_to_tape (int in_des, int out_des, off_t num_bytes, char *filename);
42 void copy_files_disk_to_disk (int in_des, int out_des, off_t num_bytes, char *filename);
43 void warn_if_file_changed (char *file_name, off_t old_file_size,
44- time_t old_file_mtime);
45+ time_t old_file_mtime);
46 void create_all_directories (char const *name);
47 void prepare_append (int out_file_des);
48 char *find_inode_file (ino_t node_num,
49@@ -190,7 +190,7 @@ void set_new_media_message (char *message);
50 #ifdef HPUX_CDF
51 char *add_cdf_double_slashes (char *filename);
52 #endif
53-void write_nuls_to_file (off_t num_bytes, int out_des,
54+void write_nuls_to_file (off_t num_bytes, int out_des,
55 void (*writer) (char *in_buf,
56 int out_des, off_t num_bytes));
57 #define DISK_IO_BLOCK_SIZE 512
58@@ -234,6 +234,5 @@ void delay_set_stat (char const *file_name, struct stat *st,
59 mode_t invert_permissions);
60 int repair_delayed_set_stat (struct cpio_file_stat *file_hdr);
61 void apply_delayed_set_stat (void);
62-
63-int arf_stores_inode_p (enum archive_format arf);
64
65+int arf_stores_inode_p (enum archive_format arf);
66diff --git a/src/global.c b/src/global.c
67index d33516f..7c4bca8 100644
68--- a/src/global.c
69+++ b/src/global.c
70@@ -113,7 +113,7 @@ int debug_flag = false;
71
72 /* File position of last header read. Only used during -A to determine
73 where the old TRAILER!!! record started. */
74-int last_header_start = 0;
75+off_t last_header_start = 0;
76
77 /* With -i; if true, copy only files that match any of the given patterns;
78 if false, copy only files that do not match any of the patterns. (-f) */
79diff --git a/src/util.c b/src/util.c
80index a38333a..7415e10 100644
81--- a/src/util.c
82+++ b/src/util.c
83@@ -59,8 +59,8 @@ tape_empty_output_buffer (int out_des)
84 static long output_bytes_before_lseek = 0;
85
86 /* Some tape drivers seem to have a signed internal seek pointer and
87- they lose if it overflows and becomes negative (e.g. when writing
88- tapes > 2Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
89+ they lose if it overflows and becomes negative (e.g. when writing
90+ tapes > 2Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
91 seek pointer and prevent it from overflowing. */
92 if (output_is_special
93 && ( (output_bytes_before_lseek += output_size) >= 1073741824L) )
94@@ -104,7 +104,7 @@ static ssize_t sparse_write (int fildes, char *buf, size_t nbyte, bool flush);
95 descriptor OUT_DES and reset `output_size' and `out_buff'.
96 If `swapping_halfwords' or `swapping_bytes' is set,
97 do the appropriate swapping first. Our callers have
98- to make sure to only set these flags if `output_size'
99+ to make sure to only set these flags if `output_size'
100 is appropriate (a multiple of 4 for `swapping_halfwords',
101 2 for `swapping_bytes'). The fact that DISK_IO_BLOCK_SIZE
102 must always be a multiple of 4 helps us (and our callers)
103@@ -186,8 +186,8 @@ tape_fill_input_buffer (int in_des, int num_bytes)
104 {
105 #ifdef BROKEN_LONG_TAPE_DRIVER
106 /* Some tape drivers seem to have a signed internal seek pointer and
107- they lose if it overflows and becomes negative (e.g. when writing
108- tapes > 4Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
109+ they lose if it overflows and becomes negative (e.g. when writing
110+ tapes > 4Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
111 seek pointer and prevent it from overflowing. */
112 if (input_is_special
113 && ( (input_bytes_before_lseek += num_bytes) >= 1073741824L) )
114@@ -330,8 +330,8 @@ tape_buffered_peek (char *peek_buf, int in_des, int num_bytes)
115
116 #ifdef BROKEN_LONG_TAPE_DRIVER
117 /* Some tape drivers seem to have a signed internal seek pointer and
118- they lose if it overflows and becomes negative (e.g. when writing
119- tapes > 4Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
120+ they lose if it overflows and becomes negative (e.g. when writing
121+ tapes > 4Gb). Doing an lseek (des, 0, SEEK_SET) seems to reset the
122 seek pointer and prevent it from overflowing. */
123 if (input_is_special
124 && ( (input_bytes_before_lseek += num_bytes) >= 1073741824L) )
125@@ -402,7 +402,7 @@ tape_toss_input (int in_des, off_t num_bytes)
126
127 if (crc_i_flag && only_verify_crc_flag)
128 {
129- int k;
130+ int k;
131 for (k = 0; k < space_left; ++k)
132 crc += in_buff[k] & 0xff;
133 }
134@@ -414,14 +414,14 @@ tape_toss_input (int in_des, off_t num_bytes)
135 }
136
137 void
138-write_nuls_to_file (off_t num_bytes, int out_des,
139- void (*writer) (char *in_buf, int out_des, off_t num_bytes))
140+write_nuls_to_file (off_t num_bytes, int out_des,
141+ void (*writer) (char *in_buf, int out_des, off_t num_bytes))
142 {
143 off_t blocks;
144 off_t extra_bytes;
145 off_t i;
146 static char zeros_512[512];
147-
148+
149 blocks = num_bytes / sizeof zeros_512;
150 extra_bytes = num_bytes % sizeof zeros_512;
151 for (i = 0; i < blocks; ++i)
152@@ -601,7 +601,7 @@ create_all_directories (char const *name)
153 char *dir;
154
155 dir = dir_name (name);
156-
157+
158 if (dir == NULL)
159 error (PAXEXIT_FAILURE, 0, _("virtual memory exhausted"));
160
161@@ -635,9 +635,9 @@ create_all_directories (char const *name)
162 void
163 prepare_append (int out_file_des)
164 {
165- int start_of_header;
166- int start_of_block;
167- int useful_bytes_in_block;
168+ off_t start_of_header;
169+ off_t start_of_block;
170+ size_t useful_bytes_in_block;
171 char *tmp_buf;
172
173 start_of_header = last_header_start;
174@@ -695,8 +695,8 @@ inode_val_compare (const void *val1, const void *val2)
175 const struct inode_val *ival1 = val1;
176 const struct inode_val *ival2 = val2;
177 return ival1->inode == ival2->inode
178- && ival1->major_num == ival2->major_num
179- && ival1->minor_num == ival2->minor_num;
180+ && ival1->major_num == ival2->major_num
181+ && ival1->minor_num == ival2->minor_num;
182 }
183
184 static struct inode_val *
185@@ -704,10 +704,10 @@ find_inode_val (ino_t node_num, unsigned long major_num,
186 unsigned long minor_num)
187 {
188 struct inode_val sample;
189-
190+
191 if (!hash_table)
192 return NULL;
193-
194+
195 sample.inode = node_num;
196 sample.major_num = major_num;
197 sample.minor_num = minor_num;
198@@ -732,7 +732,7 @@ add_inode (ino_t node_num, char *file_name, unsigned long major_num,
199 {
200 struct inode_val *temp;
201 struct inode_val *e = NULL;
202-
203+
204 /* Create new inode record. */
205 temp = (struct inode_val *) xmalloc (sizeof (struct inode_val));
206 temp->inode = node_num;
207@@ -1003,7 +1003,7 @@ buf_all_zeros (char *buf, int bufsize)
208
209 /* Write NBYTE bytes from BUF to file descriptor FILDES, trying to
210 create holes instead of writing blockfuls of zeros.
211-
212+
213 Return the number of bytes written (including bytes in zero
214 regions) on success, -1 on error.
215
216@@ -1023,7 +1023,7 @@ sparse_write (int fildes, char *buf, size_t nbytes, bool flush)
217
218 enum { begin, in_zeros, not_in_zeros } state =
219 delayed_seek_count ? in_zeros : begin;
220-
221+
222 while (nbytes)
223 {
224 size_t rest = nbytes;
225@@ -1038,7 +1038,7 @@ sparse_write (int fildes, char *buf, size_t nbytes, bool flush)
226 if (state == not_in_zeros)
227 {
228 ssize_t bytes = buf - start_ptr + rest;
229-
230+
231 n = write (fildes, start_ptr, bytes);
232 if (n == -1)
233 return -1;
234@@ -1087,8 +1087,8 @@ sparse_write (int fildes, char *buf, size_t nbytes, bool flush)
235 if (n != 1)
236 return n;
237 delayed_seek_count = 0;
238- }
239-
240+ }
241+
242 return nwritten + seek_count;
243 }
244
245@@ -1226,7 +1226,7 @@ set_perms (int fd, struct cpio_file_stat *header)
246 if (!no_chown_flag)
247 {
248 uid_t uid = CPIO_UID (header->c_uid);
249- gid_t gid = CPIO_GID (header->c_gid);
250+ gid_t gid = CPIO_GID (header->c_gid);
251 if ((fchown_or_chown (fd, header->c_name, uid, gid) < 0)
252 && errno != EPERM)
253 chown_error_details (header->c_name, uid, gid);
254@@ -1243,13 +1243,13 @@ set_file_times (int fd,
255 const char *name, unsigned long atime, unsigned long mtime)
256 {
257 struct timespec ts[2];
258-
259+
260 memset (&ts, 0, sizeof ts);
261
262 ts[0].tv_sec = atime;
263 ts[1].tv_sec = mtime;
264
265- /* Silently ignore EROFS because reading the file won't have upset its
266+ /* Silently ignore EROFS because reading the file won't have upset its
267 timestamp if it's on a read-only filesystem. */
268 if (fdutimens (fd, name, ts) < 0 && errno != EROFS)
269 utime_error (name);
270@@ -1301,7 +1301,7 @@ cpio_safer_name_suffix (char *name, bool link_target, bool absolute_names,
271
272 /* This is a simplified form of delayed set_stat used by GNU tar.
273 With the time, both forms will merge and pass to paxutils
274-
275+
276 List of directories whose statuses we need to extract after we've
277 finished extracting their subsidiary files. If you consider each
278 contiguous subsequence of elements of the form [D]?[^D]*, where [D]
279@@ -1419,7 +1419,7 @@ cpio_mkdir (struct cpio_file_stat *file_hdr, int *setstat_delayed)
280 {
281 int rc;
282 mode_t mode = file_hdr->c_mode;
283-
284+
285 if (!(file_hdr->c_mode & S_IWUSR))
286 {
287 rc = mkdir (file_hdr->c_name, mode | S_IWUSR);
288@@ -1442,10 +1442,10 @@ cpio_create_dir (struct cpio_file_stat *file_hdr, int existing_dir)
289 {
290 int res; /* Result of various function calls. */
291 int setstat_delayed = 0;
292-
293+
294 if (to_stdout_option)
295 return 0;
296-
297+
298 /* Strip any trailing `/'s off the filename; tar puts
299 them on. We might as well do it here in case anybody
300 else does too, since they cause strange things to happen. */
301@@ -1534,7 +1534,7 @@ arf_stores_inode_p (enum archive_format arf)
302 }
303 return 1;
304 }
305-
306+
307 void
308 cpio_file_stat_init (struct cpio_file_stat *file_hdr)
309 {
310--
3112.34.1
312
diff --git a/meta/recipes-extended/cpio/cpio_2.13.bb b/meta/recipes-extended/cpio/cpio_2.13.bb
index df5e09cae8..d48429b8ce 100644
--- a/meta/recipes-extended/cpio/cpio_2.13.bb
+++ b/meta/recipes-extended/cpio/cpio_2.13.bb
@@ -13,6 +13,7 @@ SRC_URI = "${GNU_MIRROR}/cpio/cpio-${PV}.tar.gz \
13 file://CVE-2021-38185.patch \ 13 file://CVE-2021-38185.patch \
14 file://0001-Use-__alignof__-with-clang.patch \ 14 file://0001-Use-__alignof__-with-clang.patch \
15 file://0001-Wrong-CRC-with-ASCII-CRC-for-large-files.patch \ 15 file://0001-Wrong-CRC-with-ASCII-CRC-for-large-files.patch \
16 file://0001-Fix-appending-to-archives-bigger-than-2G.patch \
16 file://run-ptest \ 17 file://run-ptest \
17 " 18 "
18 19