summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Larsson <catacombae@gmail.com>2021-06-08 16:11:21 +0300
committerErik Larsson <catacombae@gmail.com>2021-06-08 16:11:21 +0300
commitfded770b55fdb3a201ad515d785c17ac35705652 (patch)
treec6725cc3ec79c73dce5b4d7233211150b3b7b1a1
parent2a15a246a1d416b17f1b958cc3a9e3e21ee5b839 (diff)
downloadsgdisk-fded770b55fdb3a201ad515d785c17ac35705652.tar.gz
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&).
-rw-r--r--gptpart.cc3
1 files changed, 0 insertions, 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