Sfoglia il codice sorgente

Fix crash when SD card is smaller than starting sector of scsi disk

Michael McMaster 8 anni fa
parent
commit
2c49dbce80
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  1. 6 0
      lib/SCSI2SD/src/firmware/geometry.c

+ 6 - 0
lib/SCSI2SD/src/firmware/geometry.c

@@ -30,10 +30,16 @@ uint32_t getScsiCapacity(
 	uint32_t capacity =
 		(sdDev.capacity - sdSectorStart - S2S_CFG_SIZE) /
 			SDSectorsPerSCSISector(bytesPerSector);
+
+
 	if (sdDev.capacity == 0)
 	{
 		capacity = 0;
 	}
+	else if (sdSectorStart >= (sdDev.capacity - S2S_CFG_SIZE))
+	{
+		capacity = 0;
+	}
 	else if (scsiSectors && (capacity > scsiSectors))
 	{
 		capacity = scsiSectors;