Compare commits

...

No commits in common. "c9" and "c8" have entirely different histories.
c9 ... c8

6 changed files with 123 additions and 70 deletions

View File

@ -1 +1 @@
406ab2596e1911c916dce677ce7e903076d94c6d SOURCES/gptfdisk-1.0.7.tar.gz 9a74bbe7805d562316e92417f71e4b03155308e6 SOURCES/gptfdisk-1.0.3.tar.gz

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/gptfdisk-1.0.7.tar.gz SOURCES/gptfdisk-1.0.3.tar.gz

View File

@ -1,24 +1,24 @@
From 49ed9305afae9865d9b748ef419b4f923ae4e86d Mon Sep 17 00:00:00 2001 From a7eaefd9bc4a91a4ca26146f784d40725cfe15fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com> From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
Date: Wed, 29 Sep 2021 15:46:37 +0200 Date: Wed, 29 Sep 2021 15:33:33 +0200
Subject: [PATCH] Fix incorrect byte order of partition names on big-endian Subject: [PATCH] Fix incorrect byte order of partition names on big-endian
systems systems
--- ---
gdisk.8 | 8 ++++++++ gdisk.8 | 8 ++++++++
gptcl.cc | 11 +++++++++++ gptcl.cc | 11 +++++++++++
gptpart.cc | 13 +++++++------ gptpart.cc | 14 +++++++-------
gptpart.h | 1 + gptpart.h | 1 +
gpttext.cc | 20 ++++++++++++++++++++ gpttext.cc | 20 ++++++++++++++++++++
gpttext.h | 1 + gpttext.h | 1 +
sgdisk.8 | 8 ++++++++ sgdisk.8 | 8 ++++++++
7 files changed, 56 insertions(+), 6 deletions(-) 7 files changed, 56 insertions(+), 7 deletions(-)
diff --git a/gdisk.8 b/gdisk.8 diff --git a/gdisk.8 b/gdisk.8
index 62f6bd2..0029b75 100644 index c2cf83d..071756c 100644
--- a/gdisk.8 --- a/gdisk.8
+++ b/gdisk.8 +++ b/gdisk.8
@@ -419,6 +419,14 @@ set features for each partition. \fBgdisk\fR supports four attributes: @@ -416,6 +416,14 @@ set features for each partition. \fBgdisk\fR supports four attributes:
aren't translated into anything useful. In practice, most OSes seem to aren't translated into anything useful. In practice, most OSes seem to
ignore these attributes. ignore these attributes.
@ -34,7 +34,7 @@ index 62f6bd2..0029b75 100644
.B c .B c
Change partition GUID. You can enter a custom unique GUID for a partition Change partition GUID. You can enter a custom unique GUID for a partition
diff --git a/gptcl.cc b/gptcl.cc diff --git a/gptcl.cc b/gptcl.cc
index 2304091..65a99e9 100644 index 6c36738..58afc8a 100644
--- a/gptcl.cc --- a/gptcl.cc
+++ b/gptcl.cc +++ b/gptcl.cc
@@ -64,6 +64,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { @@ -64,6 +64,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
@ -70,10 +70,18 @@ index 2304091..65a99e9 100644
SaveGPTBackup(backupFile); SaveGPTBackup(backupFile);
free(backupFile); free(backupFile);
diff --git a/gptpart.cc b/gptpart.cc diff --git a/gptpart.cc b/gptpart.cc
index b268cf0..b83254d 100644 index 17d6f15..82aeab0 100644
--- a/gptpart.cc --- a/gptpart.cc
+++ b/gptpart.cc +++ b/gptpart.cc
@@ -242,7 +242,6 @@ void GPTPart::SetName(const string & theName) { @@ -83,7 +83,6 @@ string GPTPart::GetDescription(void) {
size_t pos = 0 ;
while ( ( pos < NAME_SIZE ) && ( name[ pos ] != 0 ) ) {
uint16_t cp = name[ pos ++ ] ;
- if ( ! IsLittleEndian() ) ReverseBytes( & cp , 2 ) ;
// first to utf32
uint32_t uni ;
if ( cp < 0xd800 || cp > 0xdfff ) {
@@ -234,7 +233,6 @@ void GPTPart::SetName(const string & theName) {
// then to utf16le // then to utf16le
if ( uni < 0x10000 ) { if ( uni < 0x10000 ) {
name[ pos ] = (uint16_t) uni ; name[ pos ] = (uint16_t) uni ;
@ -81,7 +89,7 @@ index b268cf0..b83254d 100644
pos ++ ; pos ++ ;
} // if } // if
else { else {
@@ -252,10 +251,8 @@ void GPTPart::SetName(const string & theName) { @@ -244,10 +242,8 @@ void GPTPart::SetName(const string & theName) {
} // if } // if
uni -= 0x10000 ; uni -= 0x10000 ;
name[ pos ] = (uint16_t)( uni >> 10 ) | 0xd800 ; name[ pos ] = (uint16_t)( uni >> 10 ) | 0xd800 ;
@ -92,7 +100,7 @@ index b268cf0..b83254d 100644
pos ++ ; pos ++ ;
} }
} // for } // for
@@ -415,14 +412,18 @@ int GPTPart::DoTheyOverlap(const GPTPart & other) { @@ -407,14 +403,18 @@ int GPTPart::DoTheyOverlap(const GPTPart & other) {
// Reverse the bytes of integral data types and of the UTF-16LE name; // Reverse the bytes of integral data types and of the UTF-16LE name;
// used on big-endian systems. // used on big-endian systems.
void GPTPart::ReversePartBytes(void) { void GPTPart::ReversePartBytes(void) {
@ -115,10 +123,10 @@ index b268cf0..b83254d 100644
/**************************************** /****************************************
* Functions requiring user interaction * * Functions requiring user interaction *
diff --git a/gptpart.h b/gptpart.h diff --git a/gptpart.h b/gptpart.h
index fac514e..51bfb38 100644 index 657b3f9..ac8a725 100644
--- a/gptpart.h --- a/gptpart.h
+++ b/gptpart.h +++ b/gptpart.h
@@ -94,6 +94,7 @@ class GPTPart { @@ -93,6 +93,7 @@ class GPTPart {
void BlankPartition(void); // empty partition of data void BlankPartition(void); // empty partition of data
int DoTheyOverlap(const GPTPart & other); // returns 1 if there's overlap int DoTheyOverlap(const GPTPart & other); // returns 1 if there's overlap
void ReversePartBytes(void); // reverse byte order of all integer fields void ReversePartBytes(void); // reverse byte order of all integer fields
@ -127,7 +135,7 @@ index fac514e..51bfb38 100644
// Functions requiring user interaction // Functions requiring user interaction
void ChangeType(void); // Change the type code void ChangeType(void); // Change the type code
diff --git a/gpttext.cc b/gpttext.cc diff --git a/gpttext.cc b/gpttext.cc
index ea34444..a5f0fd8 100644 index 732d861..6de7121 100644
--- a/gpttext.cc --- a/gpttext.cc
+++ b/gpttext.cc +++ b/gpttext.cc
@@ -341,6 +341,22 @@ int GPTDataTextUI::SetName(uint32_t partNum) { @@ -341,6 +341,22 @@ int GPTDataTextUI::SetName(uint32_t partNum) {
@ -172,7 +180,7 @@ index ea34444..a5f0fd8 100644
cout << "d\tdisplay the sector alignment value\n"; cout << "d\tdisplay the sector alignment value\n";
cout << "e\trelocate backup data structures to the end of the disk\n"; cout << "e\trelocate backup data structures to the end of the disk\n";
diff --git a/gpttext.h b/gpttext.h diff --git a/gpttext.h b/gpttext.h
index afe4651..6bd22cf 100644 index 98e59af..db27246 100644
--- a/gpttext.h --- a/gpttext.h
+++ b/gpttext.h +++ b/gpttext.h
@@ -49,6 +49,7 @@ class GPTDataTextUI : public GPTData { @@ -49,6 +49,7 @@ class GPTDataTextUI : public GPTData {
@ -184,7 +192,7 @@ index afe4651..6bd22cf 100644
int DestroyGPTwPrompt(void); // Returns 1 if user proceeds int DestroyGPTwPrompt(void); // Returns 1 if user proceeds
void ShowDetails(void); void ShowDetails(void);
diff --git a/sgdisk.8 b/sgdisk.8 diff --git a/sgdisk.8 b/sgdisk.8
index 59a3d3c..3fb7ae6 100644 index 2cb18b9..3bc51f2 100644
--- a/sgdisk.8 --- a/sgdisk.8
+++ b/sgdisk.8 +++ b/sgdisk.8
@@ -182,6 +182,14 @@ backup will reflect your changes. If the GPT data structures are damaged, @@ -182,6 +182,14 @@ backup will reflect your changes. If the GPT data structures are damaged,
@ -203,5 +211,5 @@ index 59a3d3c..3fb7ae6 100644
.B \-c, \-\-change\-name=partnum:name .B \-c, \-\-change\-name=partnum:name
Change the GPT name of a partition. This name is encoded as a UTF\-16 Change the GPT name of a partition. This name is encoded as a UTF\-16
-- --
2.32.0 2.35.1

View File

@ -0,0 +1,43 @@
From e44306f00bd12f4dca2db20eaba103ff2f260d87 Mon Sep 17 00:00:00 2001
From: Rod Smith <rodsmith@rodsbooks.com>
Date: Mon, 14 Sep 2020 10:08:18 -0400
Subject: [PATCH 1/2] Fix segfault on some weird data structures
---
gpt.cc | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/gpt.cc b/gpt.cc
index 03a2156..d0242d3 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -983,6 +983,14 @@ int GPTData::LoadHeader(struct GPTHeader *header, DiskIO & disk, uint64_t sector
} // if
*crcOk = CheckHeaderCRC(&tempHeader);
+ if (tempHeader.sizeOfPartitionEntries != sizeof(GPTPart)) {
+ cerr << "Warning: Partition table header claims that the size of partition table\n";
+ cerr << "entries is " << tempHeader.sizeOfPartitionEntries << " bytes, but this program ";
+ cerr << " supports only " << sizeof(GPTPart) << "-byte entries.\n";
+ cerr << "Adjusting accordingly, but partition table may be garbage.\n";
+ tempHeader.sizeOfPartitionEntries = sizeof(GPTPart);
+ }
+
if (allOK && (numParts != tempHeader.numParts) && *crcOk) {
allOK = SetGPTSize(tempHeader.numParts, 0);
}
@@ -1000,7 +1008,10 @@ int GPTData::LoadPartitionTable(const struct GPTHeader & header, DiskIO & disk,
uint32_t sizeOfParts, newCRC;
int retval;
- if (disk.OpenForRead()) {
+ if (header.sizeOfPartitionEntries != sizeof(GPTPart)) {
+ cerr << "Error! GPT header contains invalid partition entry size!\n";
+ retval = 0;
+ } else if (disk.OpenForRead()) {
if (sector == 0) {
retval = disk.Seek(header.partitionEntriesLBA);
} else {
--
2.35.1

View File

@ -0,0 +1,27 @@
From 28ac93e737ae4e2055ff23f2ea6021b1127b40a2 Mon Sep 17 00:00:00 2001
From: Rod Smith <rodsmith@rodsbooks.com>
Date: Wed, 13 Jan 2021 10:29:24 -0500
Subject: [PATCH 2/2] Fix bug that could cause crash if a badly-formatted MBR
disk was read.
---
basicmbr.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/basicmbr.cc b/basicmbr.cc
index 8fbffd1..2da56db 100644
--- a/basicmbr.cc
+++ b/basicmbr.cc
@@ -258,7 +258,8 @@ int BasicMBRData::ReadLogicalParts(uint64_t extendedStart, int partNum) {
if (EbrLocations[i] == offset) { // already read this one; infinite logical partition loop!
cerr << "Logical partition infinite loop detected! This is being corrected.\n";
allOK = -1;
- partNum -= 1;
+ if (partNum > 0) //don't go negative
+ partNum -= 1;
} // if
} // for
EbrLocations[partNum] = offset;
--
2.35.1

View File

@ -1,16 +1,17 @@
Summary: An fdisk-like partitioning tool for GPT disks Summary: An fdisk-like partitioning tool for GPT disks
Name: gdisk Name: gdisk
Version: 1.0.7 Version: 1.0.3
Release: 5%{?dist} Release: 11%{?dist}
License: GPLv2 License: GPLv2
URL: http://www.rodsbooks.com/gdisk/ URL: http://www.rodsbooks.com/gdisk/
Group: System Environment/Base
Source0: http://downloads.sourceforge.net/gptfdisk/gptfdisk-%{version}.tar.gz Source0: http://downloads.sourceforge.net/gptfdisk/gptfdisk-%{version}.tar.gz
Patch0: gdisk-1.0.7-byteswap.patch Patch0: gdisk-1.0.3-byteswap.patch
BuildRequires: gcc-c++ Patch1: gdisk-CVE-2020-0256.patch
BuildRequires: libuuid-devel Patch2: gdisk-CVE-2021-0308.patch
BuildRequires: make
BuildRequires: ncurses-devel
BuildRequires: popt-devel BuildRequires: popt-devel
BuildRequires: libuuid-devel
BuildRequires: ncurses-devel
%description %description
An fdisk-like partitioning tool for GPT disks. GPT fdisk features a An fdisk-like partitioning tool for GPT disks. GPT fdisk features a
@ -21,6 +22,8 @@ tables, and the ability to convert MBR disks to GPT format.
%prep %prep
%setup -q -n gptfdisk-%{version} %setup -q -n gptfdisk-%{version}
%patch0 -p1 %patch0 -p1
%patch1 -p1
%patch2 -p1
chmod 0644 gdisk_test.sh chmod 0644 gdisk_test.sh
%build %build
@ -45,53 +48,25 @@ done
%{_mandir}/man8/fixparts.8* %{_mandir}/man8/fixparts.8*
%changelog %changelog
* Mon Oct 25 2021 Nikola Forró <nforro@redhat.com> - 1.0.7-5 * Tue Mar 15 2022 Nikola Forró <nforro@redhat.com> - 1.0.3-11
- Fix double byteswap on big-endian systems also while reading partition names
resolves: #2065205
* Wed Mar 02 2022 Nikola Forró <nforro@redhat.com> - 1.0.3-10
- Fix CVE-2021-0308
resolves: #2052364
* Wed Mar 02 2022 Nikola Forró <nforro@redhat.com> - 1.0.3-9
- Fix CVE-2020-0256
resolves: #2052365
* Mon Oct 25 2021 Nikola Forró <nforro@redhat.com> - 1.0.3-8
- Add upstream tests as a gating test - Add upstream tests as a gating test
related: #2006964 related: #1899990
* Wed Sep 29 2021 Nikola Forró <nforro@redhat.com> - 1.0.7-4 * Wed Sep 29 2021 Nikola Forró <nforro@redhat.com> - 1.0.3-7
- Fix incorrect byte order of partition names on big-endian systems - Fix incorrect byte order of partition names on big-endian systems
resolves: #2006964 resolves: #1899990
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.0.7-3
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com> - 1.0.7-2
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Thu Mar 11 2021 Terje Rosten <terje.rosten@ntnu.no> - 1.0.7-1
- 1.0.7
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Jan 19 2021 Terje Rosten <terje.rosten@ntnu.no> - 1.0.6-1
- 1.0.6
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Sun Mar 22 2020 Terje Rosten <terje.rosten@ntnu.no> - 1.0.5-1
- 1.0.5
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.4-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sat Jul 14 2018 Terje Rosten <terje.rosten@ntnu.no> - 1.0.4-3
- Add c++ compiler
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Sun Jul 08 2018 Terje Rosten <terje.rosten@ntnu.no> - 1.0.4-1
- 1.0.4
* Fri Feb 23 2018 Florian Weimer <fweimer@redhat.com> - 1.0.3-6 * Fri Feb 23 2018 Florian Weimer <fweimer@redhat.com> - 1.0.3-6
- Use LDFLAGS from redhat-rpm-config - Use LDFLAGS from redhat-rpm-config