summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wendler <polynomial-c@gentoo.org>2021-07-05 14:19:53 +0200
committerLars Wendler <polynomial-c@gentoo.org>2021-07-05 14:20:24 +0200
commit020a3783272ae302333d167a3ce37dc4bdfcffec (patch)
treec543766836cb0d0329f6ed34403d7713b44ce40b /sys-apps/gptfdisk
parentdev-ruby/loquacious: add ruby27; EAPI 7 (diff)
downloadgentoo-020a3783272ae302333d167a3ce37dc4bdfcffec.tar.gz
gentoo-020a3783272ae302333d167a3ce37dc4bdfcffec.tar.bz2
gentoo-020a3783272ae302333d167a3ce37dc4bdfcffec.zip
sys-apps/gptfdisk: Added a patch to remove byteswap
Closes: https://bugs.gentoo.org/797412 Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
Diffstat (limited to 'sys-apps/gptfdisk')
-rw-r--r--sys-apps/gptfdisk/files/gptfdisk-1.0.7-remove_byteswap.patch50
-rw-r--r--sys-apps/gptfdisk/gptfdisk-1.0.7.ebuild4
2 files changed, 54 insertions, 0 deletions
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
new file mode 100644
index 000000000000..c1874d6edd7c
--- /dev/null
+++ b/sys-apps/gptfdisk/files/gptfdisk-1.0.7-remove_byteswap.patch
@@ -0,0 +1,50 @@
+From fded770b55fdb3a201ad515d785c17ac35705652 Mon Sep 17 00:00:00 2001
+From: Erik Larsson <catacombae@gmail.com>
+Date: Tue, 8 Jun 2021 16:11:21 +0300
+Subject: [PATCH] gptpart.cc: Remove byteswap commands in
+ GPTPart::SetName(const string&).
+
+The byteswapping done in GPTPart::SetName(const string&) was reversed
+later when GPTPart::ReversePartBytes() was called.
+
+The intended design seems to have been to keep the fields in native
+endianness until just before the partition is written to disk when all
+the GPTPart data is byteswapped all at once with a call to
+GPTPart::ReversePartBytes().
+However this was defeated by leaving the original byteswaps in there and
+effectively the name was swapped back to the native-endian form. For big
+endian systems this meant that a UTF-16BE string was written to disk,
+violating the specification and causing interoperability problems.
+
+Fixed by removing these inline byteswaps in GPTPart::SetName(const
+string&).
+---
+ gptpart.cc | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/gptpart.cc b/gptpart.cc
+index 81bbcf0..841140a 100644
+--- a/gptpart.cc
++++ b/gptpart.cc
+@@ -242,7 +242,6 @@ void GPTPart::SetName(const string & theName) {
+ // then to utf16le
+ if ( uni < 0x10000 ) {
+ name[ pos ] = (uint16_t) uni ;
+- if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ;
+ pos ++ ;
+ } // if
+ else {
+@@ -252,10 +251,8 @@ void GPTPart::SetName(const string & theName) {
+ } // if
+ uni -= 0x10000 ;
+ name[ pos ] = (uint16_t)( uni >> 10 ) | 0xd800 ;
+- if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ;
+ pos ++ ;
+ name[ pos ] = (uint16_t)( uni & 0x3ff ) | 0xdc00 ;
+- if ( ! IsLittleEndian() ) ReverseBytes( name + pos , 2 ) ;
+ pos ++ ;
+ }
+ } // for
+--
+2.32.0
+
diff --git a/sys-apps/gptfdisk/gptfdisk-1.0.7.ebuild b/sys-apps/gptfdisk/gptfdisk-1.0.7.ebuild
index 9093cf2c58db..d34745b703bc 100644
--- a/sys-apps/gptfdisk/gptfdisk-1.0.7.ebuild
+++ b/sys-apps/gptfdisk/gptfdisk-1.0.7.ebuild
@@ -30,6 +30,10 @@ DEPEND="
"
BDEPEND="virtual/pkgconfig"
+PATCHES=(
+ "${FILESDIR}/${P}-remove_byteswap.patch" #797412
+)
+
src_prepare() {
default