Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

PIT files are no longer always exactly 4096 bytes. Fixed a bug that w…

…as a

result of making this assumption.
  • Loading branch information...
commit 8ac74126b4d8a295031ada29e3ff72d4fc5acbf4 1 parent 4f32206
@Benjamin-Dobell authored
Showing with 18 additions and 7 deletions.
  1. +18 −7 heimdall/source/FlashAction.cpp
View
25 heimdall/source/FlashAction.cpp
@@ -444,21 +444,32 @@ static PitData *getPitData(const map<string, FILE *>& argumentFileMap, BridgeMan
FILE *localPitFile = localPitFileIt->second;
// Load the local pit file into memory.
- unsigned char *pitFileBuffer = new unsigned char[4096];
- memset(pitFileBuffer, 0, 4096);
-
fseek(localPitFile, 0, SEEK_END);
long localPitFileSize = ftell(localPitFile);
rewind(localPitFile);
+ unsigned char *pitFileBuffer = new unsigned char[localPitFileSize];
+ memset(pitFileBuffer, 0, localPitFileSize);
+
// dataRead is discarded, it's here to remove warnings.
int dataRead = fread(pitFileBuffer, 1, localPitFileSize, localPitFile);
- rewind(localPitFile);
- localPitData = new PitData();
- localPitData->Unpack(pitFileBuffer);
+ if (dataRead > 0)
+ {
+ rewind(localPitFile);
- delete [] pitFileBuffer;
+ localPitData = new PitData();
+ localPitData->Unpack(pitFileBuffer);
+
+ delete [] pitFileBuffer;
+ }
+ else
+ {
+ Interface::PrintError("Failed to read PIT file.\n");
+
+ delete [] pitFileBuffer;
+ return (nullptr);
+ }
}
if (repartition)
Please sign in to comment.
Something went wrong with that request. Please try again.