1 |
commit: 87b2ad7537c7e49e39496e1b6f76eff34e42b438 |
2 |
Author: matoro <matoro <AT> users <DOT> noreply <DOT> github <DOT> com> |
3 |
AuthorDate: Sun Jul 10 21:48:01 2022 +0000 |
4 |
Commit: Jakov Smolić <jsmolic <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jul 31 12:07:05 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=87b2ad75 |
7 |
|
8 |
sys-fs/genext2fs: revbump 1.5.0-r1, apply sparc SIGBUS patch |
9 |
|
10 |
Addresses https://bugs.gentoo.org/829270 by backporting my patch from |
11 |
https://github.com/bestouff/genext2fs/pull/32 |
12 |
|
13 |
Bug: https://bugs.gentoo.org/828930 |
14 |
Closes: https://bugs.gentoo.org/829270 |
15 |
Signed-off-by: matoro <matoro <AT> users.noreply.github.com> |
16 |
Closes: https://github.com/gentoo/gentoo/pull/26332 |
17 |
Signed-off-by: Jakov Smolić <jsmolic <AT> gentoo.org> |
18 |
|
19 |
sys-fs/genext2fs/files/backport-pr-32.patch | 94 +++++++++++++++++++++++++++++ |
20 |
sys-fs/genext2fs/genext2fs-1.5.0-r1.ebuild | 21 +++++++ |
21 |
2 files changed, 115 insertions(+) |
22 |
|
23 |
diff --git a/sys-fs/genext2fs/files/backport-pr-32.patch b/sys-fs/genext2fs/files/backport-pr-32.patch |
24 |
new file mode 100644 |
25 |
index 000000000000..92c67e02031d |
26 |
--- /dev/null |
27 |
+++ b/sys-fs/genext2fs/files/backport-pr-32.patch |
28 |
@@ -0,0 +1,94 @@ |
29 |
+From 9651f5df1c95cdfee3d8f5f3f989fe326547f5d0 Mon Sep 17 00:00:00 2001 |
30 |
+From: matoro <matoro@××××××××××××××××××××.com> |
31 |
+Date: Mon, 16 May 2022 21:54:21 -0400 |
32 |
+Subject: [PATCH 1/2] Fix alignment issues for strict architectures |
33 |
+ |
34 |
+Fixes two locations where unaligned accesses will cause bus errors on |
35 |
+architectures that are strict about such accesses, namely sparc. |
36 |
+ |
37 |
+The first is in swab32_into, which is called with an offset of +1 into |
38 |
+an unsigned char array from mklink_fs. |
39 |
+ |
40 |
+The second is in add2fs_from_tarball when checking the validity of a |
41 |
+tarball, which casts a string from an unaligned position inside a struct |
42 |
+to a long. |
43 |
+ |
44 |
+After these changes, the test suite passes on sparc. |
45 |
+--- |
46 |
+ genext2fs.c | 15 +++++++++------ |
47 |
+ 1 file changed, 9 insertions(+), 6 deletions(-) |
48 |
+ |
49 |
+diff --git a/genext2fs.c b/genext2fs.c |
50 |
+index 96bbb43..404f31e 100644 |
51 |
+--- a/genext2fs.c |
52 |
++++ b/genext2fs.c |
53 |
+@@ -2058,11 +2058,14 @@ mkdir_fs(filesystem *fs, uint32 parent_nod, const char *name, uint32 mode, |
54 |
+ |
55 |
+ // byte swapping for symlinks |
56 |
+ static inline void |
57 |
+-swab32_into(uint32 *dst, uint32 *src, size_t n) |
58 |
++swab32_into(uint32 *dst, uint8 *src, size_t n) |
59 |
+ { |
60 |
+ size_t i; |
61 |
+- for(i = 0; i < n; i++) |
62 |
+- dst[i] = swab32(src[i]); |
63 |
++ for(i = 0; i < n; i++) { |
64 |
++ uint32 tmp_buf; |
65 |
++ memcpy(&tmp_buf, src + i * sizeof(uint32) / sizeof(uint8), sizeof(uint32) / sizeof(uint8)); |
66 |
++ dst[i] = swab32(tmp_buf); |
67 |
++ } |
68 |
+ } |
69 |
+ |
70 |
+ // make a symlink |
71 |
+@@ -2079,7 +2082,7 @@ mklink_fs(filesystem *fs, uint32 parent_nod, const char *name, size_t size, uint |
72 |
+ |
73 |
+ if (size < 4 * (EXT2_TIND_BLOCK + 1)) |
74 |
+ if (fs->swapit) |
75 |
+- swab32_into(node->i_block, (uint32 *)b, EXT2_TIND_BLOCK + 1); |
76 |
++ swab32_into(node->i_block, b, EXT2_TIND_BLOCK + 1); |
77 |
+ else |
78 |
+ memcpy(node->i_block, b, 4 * (EXT2_TIND_BLOCK + 1)); |
79 |
+ else |
80 |
+@@ -2290,7 +2293,7 @@ add2fs_from_tarball(filesystem *fs, uint32 this_nod, FILE * fh, int squash_uids, |
81 |
+ continue; |
82 |
+ } else |
83 |
+ nbnull = 0; |
84 |
+- if (*(long *)tarhead->ustar != *(long *)"ustar\00000" && strcmp(tarhead->ustar, "ustar ")) |
85 |
++ if (memcmp(tarhead->ustar, "ustar\00000", sizeof(long)) && strcmp(tarhead->ustar, "ustar ")) |
86 |
+ error_msg_and_die("not a tarball"); |
87 |
+ signed_checksum = unsigned_checksum = 0; |
88 |
+ checksum = OCTAL_READ(tarhead->checksum); |
89 |
+@@ -3351,7 +3354,7 @@ print_link(filesystem *fs, uint32 nod) |
90 |
+ uint32 *buf = malloc(4 * (EXT2_TIND_BLOCK + 1)); |
91 |
+ if (buf == NULL) |
92 |
+ error_msg_and_die(memory_exhausted); |
93 |
+- swab32_into(buf, node->i_block, EXT2_TIND_BLOCK + 1); |
94 |
++ swab32_into(buf, (uint8*)node->i_block, EXT2_TIND_BLOCK + 1); |
95 |
+ printf("links to '%s'\n", (char*) buf); |
96 |
+ free(buf); |
97 |
+ } else { |
98 |
+ |
99 |
+From 4a99c22603fb01ca8d6c6c4cb9873f50124ac025 Mon Sep 17 00:00:00 2001 |
100 |
+From: matoro <matoro@××××××××××××××××××××.com> |
101 |
+Date: Wed, 18 May 2022 11:46:44 -0400 |
102 |
+Subject: [PATCH 2/2] Hardcode length of hardcoded char array instead of |
103 |
+ sizeof(long) |
104 |
+ |
105 |
+sizeof(long) != 8 on 32-bit. |
106 |
+--- |
107 |
+ genext2fs.c | 2 +- |
108 |
+ 1 file changed, 1 insertion(+), 1 deletion(-) |
109 |
+ |
110 |
+diff --git a/genext2fs.c b/genext2fs.c |
111 |
+index 404f31e..e8c71ff 100644 |
112 |
+--- a/genext2fs.c |
113 |
++++ b/genext2fs.c |
114 |
+@@ -2293,7 +2293,7 @@ add2fs_from_tarball(filesystem *fs, uint32 this_nod, FILE * fh, int squash_uids, |
115 |
+ continue; |
116 |
+ } else |
117 |
+ nbnull = 0; |
118 |
+- if (memcmp(tarhead->ustar, "ustar\00000", sizeof(long)) && strcmp(tarhead->ustar, "ustar ")) |
119 |
++ if (memcmp(tarhead->ustar, "ustar\00000", 8) && strcmp(tarhead->ustar, "ustar ")) |
120 |
+ error_msg_and_die("not a tarball"); |
121 |
+ signed_checksum = unsigned_checksum = 0; |
122 |
+ checksum = OCTAL_READ(tarhead->checksum); |
123 |
|
124 |
diff --git a/sys-fs/genext2fs/genext2fs-1.5.0-r1.ebuild b/sys-fs/genext2fs/genext2fs-1.5.0-r1.ebuild |
125 |
new file mode 100644 |
126 |
index 000000000000..35487c327f55 |
127 |
--- /dev/null |
128 |
+++ b/sys-fs/genext2fs/genext2fs-1.5.0-r1.ebuild |
129 |
@@ -0,0 +1,21 @@ |
130 |
+# Copyright 1999-2022 Gentoo Authors |
131 |
+# Distributed under the terms of the GNU General Public License v2 |
132 |
+ |
133 |
+EAPI=8 |
134 |
+ |
135 |
+inherit autotools |
136 |
+ |
137 |
+DESCRIPTION="generate ext2 file systems" |
138 |
+HOMEPAGE="https://github.com/bestouff/genext2fs" |
139 |
+SRC_URI="https://github.com/bestouff/genext2fs/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz" |
140 |
+ |
141 |
+LICENSE="GPL-2" |
142 |
+SLOT="0" |
143 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~sparc ~x86" |
144 |
+ |
145 |
+PATCHES=( "${FILESDIR}/backport-pr-32.patch" ) |
146 |
+ |
147 |
+src_prepare() { |
148 |
+ default |
149 |
+ eautoreconf |
150 |
+} |