aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2018-03-27 13:17:19 -0600
committerJeff Sharkey <jsharkey@android.com>2018-03-27 13:19:51 -0600
commit9c50b5e176b95034b54d04856388ac3be6132076 (patch)
treecb5aace965dfdc6bc506df908b473cdf2b676e21
parentfe263b2505fe71584149874ee8a441149676bd9a (diff)
downloadgptfdisk-pie-qpr1-s3-release.tar.gz
On 32-bit devices we trigger SIGBUS by trying to copy around the std::string, so parse it immediately to avoid trouble. Test: manual with 32-bit binary Bug: 73961200 Change-Id: I32028fd18a00f3a40d380145cb7a7874b758f5c4
-rw-r--r--gptcl.cc10
-rw-r--r--gptcl.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/gptcl.cc b/gptcl.cc
index f80db25..6e1f89f 100644
--- a/gptcl.cc
+++ b/gptcl.cc
@@ -365,7 +365,10 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
partNum = newPartNum;
if ((partNum >= 0) && (partNum < (int) GetNumParts())) {
// Remember the original hex value requested
- typeRaw[partNum] = GetString(typeCode, 2);
+ string raw = GetString(typeCode, 2);
+ if (raw.size() == 4) {
+ typeRaw[partNum] = StrToHex(raw, 0);
+ }
typeHelper = GetString(typeCode, 2);
if ((typeHelper != (GUIDData) "00000000-0000-0000-0000-000000000000") &&
(ChangePartType(partNum, typeHelper))) {
@@ -499,10 +502,7 @@ int GPTDataCL::BuildMBR(char* argument, int isHybrid) {
// If we were created with a specific hex type, use that instead
// of risking fidelity loss by doing a GUID-based lookup
if (typeRaw.count(origPartNum) == 1) {
- string raw = typeRaw[origPartNum];
- if (raw.size() == 4) {
- newPart.SetType(StrToHex(raw, 0));
- }
+ newPart.SetType(typeRaw[origPartNum]);
}
newMBR.AddPart(i + isHybrid, newPart);
} else {
diff --git a/gptcl.h b/gptcl.h
index 7484a49..d8fa9ff 100644
--- a/gptcl.h
+++ b/gptcl.h
@@ -37,7 +37,7 @@ class GPTDataCL : public GPTData {
int alignment, deletePartNum, infoPartNum, largestPartNum, bsdPartNum;
uint32_t tableSize;
poptContext poptCon;
- std::map<int, string> typeRaw;
+ std::map<int, char> typeRaw;
int BuildMBR(char* argument, int isHybrid);
public: