More sanity checking; if we get a good header followed immediately by a bad

one, then the header is no longer valid.
This commit is contained in:
David Given
2019-02-23 20:50:27 +01:00
parent 649c571f81
commit 5b519ba675

View File

@@ -69,19 +69,19 @@ SectorVector BrotherDecoder::decodeToSectors(const RawRecordVector& rawRecords,
{
case BROTHER_SECTOR_RECORD:
{
headerIsValid = false;
if (rawrecord->data.size() < (32+32))
{
headerIsValid = false;
break;
}
nextTrack = decode_header_gcr(read_be16(toBytes(ii+32, ii+48)));
nextSector = decode_header_gcr(read_be16(toBytes(ii+48, ii+64)));
/* Sanity check the sector; sector IDs above 11 can't exist but appear
* occasionally due to read bit errors. */
/* Sanity check the values read; there's no header checksum and
* occasionally we get garbage due to bit errors. */
if (nextSector > 11)
break;
if (nextTrack > 79)
break;
headerIsValid = true;
break;