Fix crash in IsSCAssem

The test for "is this an S-C Assembler source file" tried to
dereference a null pointer when asked to examine a file with a
zero-length data fork.  The test only fires for files with type=INT
and auxType=0, so this is pretty hard to hit.  The specific failing
case had a damaged file with the appropriate file type.

Issue #42
This commit is contained in:
Andy McFadden 2020-08-03 13:47:42 -07:00
parent a85ceca75f
commit 5e9d8f0102
3 changed files with 8 additions and 4 deletions

View File

@ -81,7 +81,11 @@ void ReformatSCAssem::Examine(ReformatHolder* pHolder)
long srcLen = pHolder->GetSourceLen(ReformatHolder::kPartData);
int len;
len = *ptr;
if (srcLen < 1) {
return false;
}
len = *ptr; // get length byte
if (len == 0 || len > srcLen)
return false; // should return an error, really
if (ptr[len-1] == 0x00) {

View File

@ -208,7 +208,7 @@ public:
for (i = 0; i < kReformatMAX; i++)
fApplies[part][i] = kApplicUnknown;
fSourceBuf[part] = NULL;
fSourceLen[part] = NULL;
fSourceLen[part] = 0;
fErrorBuf[part] = NULL;
}
for (i = 0; i < kReformatMAX; i++) {
@ -356,7 +356,7 @@ private:
char* fNameExt; // guaranteed non-NULL
/* input goes here */
uint8_t* fSourceBuf[kPartMAX];
uint8_t* fSourceBuf[kPartMAX];
long fSourceLen[kPartMAX];
char* fErrorBuf[kPartMAX];

View File

@ -139,7 +139,7 @@ private:
/*
* Abstract base class for reformatting a graphics file into a
* device-independent bitmap..
* device-independent bitmap.
*/
class ReformatGraphics: public Reformat {
public: