Fixed bug in sgdisk that could cause segfault when passing an invalid
partition number to -i/--info; added patch to fix compiling problems with some versions of GCC.
This commit is contained in:
3
NEWS
3
NEWS
@@ -1,6 +1,9 @@
|
||||
0.8.8 (?/??/2013):
|
||||
------------------
|
||||
|
||||
- Fixed bug that could cause segfault when passing an invalid partition
|
||||
number to sgdisk's -i/--info command.
|
||||
|
||||
- Added new type code: 933AC7E1-2EB4-4F13-B844-0E14E2AEF915, or gdisk code
|
||||
8302, for Linux /home partitions. This type code is used by recent
|
||||
versions of systemd to permit /home to be auto-mounted; see
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
38
gpt.cc
38
gpt.cc
@@ -573,7 +573,7 @@ int GPTData::FindHybridMismatches(void) {
|
||||
mbrFirst = (uint64_t) protectiveMBR.GetFirstSector(i);
|
||||
mbrLast = mbrFirst + (uint64_t) protectiveMBR.GetLength(i) - UINT64_C(1);
|
||||
do {
|
||||
if ((partitions[j].GetFirstLBA() == mbrFirst) &&
|
||||
if ((j < numParts) && (partitions[j].GetFirstLBA() == mbrFirst) &&
|
||||
(partitions[j].GetLastLBA() == mbrLast) && (partitions[j].IsUsed()))
|
||||
found = 1;
|
||||
j++;
|
||||
@@ -1411,10 +1411,10 @@ void GPTData::DisplayGPTData(void) {
|
||||
|
||||
// Show detailed information on the specified partition
|
||||
void GPTData::ShowPartDetails(uint32_t partNum) {
|
||||
if (!IsFreePartNum(partNum)) {
|
||||
if ((partNum < numParts) && !IsFreePartNum(partNum)) {
|
||||
partitions[partNum].ShowDetails(blockSize);
|
||||
} else {
|
||||
cout << "Partition #" << partNum + 1 << " does not exist.";
|
||||
cout << "Partition #" << partNum + 1 << " does not exist.\n";
|
||||
} // if
|
||||
} // GPTData::ShowPartDetails()
|
||||
|
||||
@@ -2332,32 +2332,38 @@ int GPTData::ManageAttributes(int partNum, const string & command, const string
|
||||
int retval = 0;
|
||||
Attributes theAttr;
|
||||
|
||||
if (command == "show") {
|
||||
ShowAttributes(partNum);
|
||||
} else if (command == "get") {
|
||||
GetAttribute(partNum, bits);
|
||||
if (partNum >= (int) numParts) {
|
||||
cerr << "Invalid partition number (" << partNum + 1 << ")\n";
|
||||
retval = -1;
|
||||
} else {
|
||||
theAttr = partitions[partNum].GetAttributes();
|
||||
if (theAttr.OperateOnAttributes(partNum, command, bits)) {
|
||||
partitions[partNum].SetAttributes(theAttr.GetAttributes());
|
||||
retval = 1;
|
||||
if (command == "show") {
|
||||
ShowAttributes(partNum);
|
||||
} else if (command == "get") {
|
||||
GetAttribute(partNum, bits);
|
||||
} else {
|
||||
retval = -1;
|
||||
} // if/else
|
||||
} // if/elseif/else
|
||||
theAttr = partitions[partNum].GetAttributes();
|
||||
if (theAttr.OperateOnAttributes(partNum, command, bits)) {
|
||||
partitions[partNum].SetAttributes(theAttr.GetAttributes());
|
||||
retval = 1;
|
||||
} else {
|
||||
retval = -1;
|
||||
} // if/else
|
||||
} // if/elseif/else
|
||||
} // if/else invalid partition #
|
||||
|
||||
return retval;
|
||||
} // GPTData::ManageAttributes()
|
||||
|
||||
// Show all attributes for a specified partition....
|
||||
void GPTData::ShowAttributes(const uint32_t partNum) {
|
||||
if (partitions[partNum].IsUsed())
|
||||
if ((partNum < numParts) && partitions[partNum].IsUsed())
|
||||
partitions[partNum].ShowAttributes(partNum);
|
||||
} // GPTData::ShowAttributes
|
||||
|
||||
// Show whether a single attribute bit is set (terse output)...
|
||||
void GPTData::GetAttribute(const uint32_t partNum, const string& attributeBits) {
|
||||
partitions[partNum].GetAttributes().OperateOnAttributes(partNum, "get", attributeBits);
|
||||
if (partNum < numParts)
|
||||
partitions[partNum].GetAttributes().OperateOnAttributes(partNum, "get", attributeBits);
|
||||
} // GPTData::GetAttribute
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef __GPTSUPPORT
|
||||
#define __GPTSUPPORT
|
||||
|
||||
#define GPTFDISK_VERSION "0.8.7.3"
|
||||
#define GPTFDISK_VERSION "0.8.7.4"
|
||||
|
||||
#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
|
||||
// Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64
|
||||
|
||||
Reference in New Issue
Block a user