]> localhost Git - SCSI2SD-V6.git/commitdiff
Fix crash when SD card is smaller than starting sector of scsi disk
authorMichael McMaster <michael@codesrc.com>
Sat, 29 Apr 2017 04:40:25 +0000 (14:40 +1000)
committerMichael McMaster <michael@codesrc.com>
Sat, 29 Apr 2017 04:40:25 +0000 (14:40 +1000)
src/firmware/geometry.c

index 52e87b9e680ab047212477fbdd55385532b22a59..44a2e82bc3619f55bdcd5d5bb670f1cf3af42f61 100755 (executable)
@@ -30,10 +30,16 @@ uint32_t getScsiCapacity(
        uint32_t capacity =\r
                (sdDev.capacity - sdSectorStart - S2S_CFG_SIZE) /\r
                        SDSectorsPerSCSISector(bytesPerSector);\r
+\r
+\r
        if (sdDev.capacity == 0)\r
        {\r
                capacity = 0;\r
        }\r
+       else if (sdSectorStart >= (sdDev.capacity - S2S_CFG_SIZE))\r
+       {\r
+               capacity = 0;\r
+       }\r
        else if (scsiSectors && (capacity > scsiSectors))\r
        {\r
                capacity = scsiSectors;\r