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