Commit ff654269 authored by thrust26's avatar thrust26
Browse files

safety fix for unusual small ROMs.

parent 8c812893
......@@ -85,21 +85,22 @@ string ControllerDetector::autodetectPort(const uInt8* image, uInt32 size,
bool ControllerDetector::searchForBytes(const uInt8* image, uInt32 imagesize,
const uInt8* signature, uInt32 sigsize)
{
for(uInt32 i = 0; i < imagesize - sigsize; ++i)
{
uInt32 matches = 0;
for(uInt32 j = 0; j < sigsize; ++j)
{
if(image[i + j] == signature[j])
++matches;
else
break;
}
if(matches == sigsize)
if (imagesize >= sigsize)
for(uInt32 i = 0; i < imagesize - sigsize; ++i)
{
return true;
uInt32 matches = 0;
for(uInt32 j = 0; j < sigsize; ++j)
{
if(image[i + j] == signature[j])
++matches;
else
break;
}
if(matches == sigsize)
{
return true;
}
}
}
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment