diff options
Diffstat (limited to 'meta/recipes-extended/cpio/cpio-2.13/0003-Fix-calculation-of-CRC-in-copy-out-mode.patch')
-rw-r--r-- | meta/recipes-extended/cpio/cpio-2.13/0003-Fix-calculation-of-CRC-in-copy-out-mode.patch | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/meta/recipes-extended/cpio/cpio-2.13/0003-Fix-calculation-of-CRC-in-copy-out-mode.patch b/meta/recipes-extended/cpio/cpio-2.13/0003-Fix-calculation-of-CRC-in-copy-out-mode.patch new file mode 100644 index 0000000000..2dfd348d7c --- /dev/null +++ b/meta/recipes-extended/cpio/cpio-2.13/0003-Fix-calculation-of-CRC-in-copy-out-mode.patch | |||
@@ -0,0 +1,58 @@ | |||
1 | From d257e47a6c6b41ba727b196ac96c05ab91bd9d65 Mon Sep 17 00:00:00 2001 | ||
2 | From: Sergey Poznyakoff <gray@gnu.org> | ||
3 | Date: Fri, 7 Apr 2023 11:23:37 +0300 | ||
4 | Subject: [PATCH 3/4] Fix calculation of CRC in copy-out mode. | ||
5 | |||
6 | * src/copyout.c (read_for_checksum): Fix type of the file_size argument. | ||
7 | Rewrite the reading loop. | ||
8 | |||
9 | Original patch by Stefano Babic <sbabic@denx.de> | ||
10 | |||
11 | Upstream-Status: Backport [a1b2f7871c3ae5113e0102b870b15ea06a8f0e3d] | ||
12 | Signed-off-by: Marek Vasut <marex@denx.de> | ||
13 | --- | ||
14 | src/copyout.c | 16 +++++++--------- | ||
15 | 1 file changed, 7 insertions(+), 9 deletions(-) | ||
16 | |||
17 | diff --git a/src/copyout.c b/src/copyout.c | ||
18 | index 8b0beb6..f1ff351 100644 | ||
19 | --- a/src/copyout.c | ||
20 | +++ b/src/copyout.c | ||
21 | @@ -34,27 +34,25 @@ | ||
22 | compute and return a checksum for them. */ | ||
23 | |||
24 | static uint32_t | ||
25 | -read_for_checksum (int in_file_des, int file_size, char *file_name) | ||
26 | +read_for_checksum (int in_file_des, off_t file_size, char *file_name) | ||
27 | { | ||
28 | uint32_t crc; | ||
29 | - char buf[BUFSIZ]; | ||
30 | - int bytes_left; | ||
31 | - int bytes_read; | ||
32 | - int i; | ||
33 | + unsigned char buf[BUFSIZ]; | ||
34 | + ssize_t bytes_read; | ||
35 | + ssize_t i; | ||
36 | |||
37 | crc = 0; | ||
38 | |||
39 | - for (bytes_left = file_size; bytes_left > 0; bytes_left -= bytes_read) | ||
40 | + while (file_size > 0) | ||
41 | { | ||
42 | bytes_read = read (in_file_des, buf, BUFSIZ); | ||
43 | if (bytes_read < 0) | ||
44 | error (PAXEXIT_FAILURE, errno, _("cannot read checksum for %s"), file_name); | ||
45 | if (bytes_read == 0) | ||
46 | break; | ||
47 | - if (bytes_left < bytes_read) | ||
48 | - bytes_read = bytes_left; | ||
49 | - for (i = 0; i < bytes_read; ++i) | ||
50 | + for (i = 0; i < bytes_read; i++) | ||
51 | crc += buf[i] & 0xff; | ||
52 | + file_size -= bytes_read; | ||
53 | } | ||
54 | if (lseek (in_file_des, 0L, SEEK_SET)) | ||
55 | error (PAXEXIT_FAILURE, errno, _("cannot read checksum for %s"), file_name); | ||
56 | -- | ||
57 | 2.39.2 | ||
58 | |||