1 |
commit: 020a3783272ae302333d167a3ce37dc4bdfcffec |
2 |
Author: Lars Wendler <polynomial-c <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jul 5 12:19:53 2021 +0000 |
4 |
Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jul 5 12:20:24 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=020a3783 |
7 |
|
8 |
sys-apps/gptfdisk: Added a patch to remove byteswap |
9 |
|
10 |
Closes: https://bugs.gentoo.org/797412 |
11 |
Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org> |
12 |
|
13 |
.../files/gptfdisk-1.0.7-remove_byteswap.patch | 50 ++++++++++++++++++++++ |
14 |
sys-apps/gptfdisk/gptfdisk-1.0.7.ebuild | 4 ++ |
15 |
2 files changed, 54 insertions(+) |
16 |
|
17 |
diff --git a/sys-apps/gptfdisk/files/gptfdisk-1.0.7-remove_byteswap.patch b/sys-apps/gptfdisk/files/gptfdisk-1.0.7-remove_byteswap.patch |
18 |
new file mode 100644 |
19 |
index 00000000000..c1874d6edd7 |
20 |
--- /dev/null |
21 |
+++ b/sys-apps/gptfdisk/files/gptfdisk-1.0.7-remove_byteswap.patch |
22 |
@@ -0,0 +1,50 @@ |
23 |
+From fded770b55fdb3a201ad515d785c17ac35705652 Mon Sep 17 00:00:00 2001 |
24 |
+From: Erik Larsson <catacombae@×××××.com> |
25 |
+Date: Tue, 8 Jun 2021 16:11:21 +0300 |
26 |
+Subject: [PATCH] gptpart.cc: Remove byteswap commands in |
27 |
+ GPTPart::SetName(const string&). |
28 |
+ |
29 |
+The byteswapping done in GPTPart::SetName(const string&) was reversed |
30 |
+later when GPTPart::ReversePartBytes() was called. |
31 |
+ |
32 |
+The intended design seems to have been to keep the fields in native |
33 |
+endianness until just before the partition is written to disk when all |
34 |
+the GPTPart data is byteswapped all at once with a call to |
35 |
+GPTPart::ReversePartBytes(). |
36 |
+However this was defeated by leaving the original byteswaps in there and |
37 |
+effectively the name was swapped back to the native-endian form. For big |
38 |
+endian systems this meant that a UTF-16BE string was written to disk, |
39 |
+violating the specification and causing interoperability problems. |
40 |
+ |
41 |
+Fixed by removing these inline byteswaps in GPTPart::SetName(const |
42 |
+string&). |
43 |
+--- |
44 |
+ gptpart.cc | 3 --- |
45 |
+ 1 file changed, 3 deletions(-) |
46 |
+ |
47 |
+diff --git a/gptpart.cc b/gptpart.cc |
48 |
+index 81bbcf0..841140a 100644 |
49 |
+--- a/gptpart.cc |
50 |
++++ b/gptpart.cc |
51 |
+@@ -242,7 +242,6 @@ void GPTPart::SetName(const string & theName) { |
52 |
+ // then to utf16le |
53 |
+ if ( uni < 0x10000 ) { |
54 |
+ name[ pos ] = (uint16_t) uni ; |
55 |
+- if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ; |
56 |
+ pos ++ ; |
57 |
+ } // if |
58 |
+ else { |
59 |
+@@ -252,10 +251,8 @@ void GPTPart::SetName(const string & theName) { |
60 |
+ } // if |
61 |
+ uni -= 0x10000 ; |
62 |
+ name[ pos ] = (uint16_t)( uni >> 10 ) | 0xd800 ; |
63 |
+- if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ; |
64 |
+ pos ++ ; |
65 |
+ name[ pos ] = (uint16_t)( uni & 0x3ff ) | 0xdc00 ; |
66 |
+- if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ; |
67 |
+ pos ++ ; |
68 |
+ } |
69 |
+ } // for |
70 |
+-- |
71 |
+2.32.0 |
72 |
+ |
73 |
|
74 |
diff --git a/sys-apps/gptfdisk/gptfdisk-1.0.7.ebuild b/sys-apps/gptfdisk/gptfdisk-1.0.7.ebuild |
75 |
index 9093cf2c58d..d34745b703b 100644 |
76 |
--- a/sys-apps/gptfdisk/gptfdisk-1.0.7.ebuild |
77 |
+++ b/sys-apps/gptfdisk/gptfdisk-1.0.7.ebuild |
78 |
@@ -30,6 +30,10 @@ DEPEND=" |
79 |
" |
80 |
BDEPEND="virtual/pkgconfig" |
81 |
|
82 |
+PATCHES=( |
83 |
+ "${FILESDIR}/${P}-remove_byteswap.patch" #797412 |
84 |
+) |
85 |
+ |
86 |
src_prepare() { |
87 |
default |