Переглянути джерело

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

Michael McMaster 8 роки тому
батько
коміт
2c49dbce80
1 змінених файлів з 6 додано та 0 видалено
  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;