Add check for disk length not aligned to sector boundary

This commit is contained in:
kris 2017-05-04 21:31:55 +01:00
parent 863fdba10f
commit 8eab43e5ee
1 changed files with 9 additions and 2 deletions

View File

@ -38,8 +38,15 @@ def main():
print "(%d/%d:%d%%) %s" % (idx+1, num_disks, (idx+1)*100/num_disks, f)
disk = bytearray(open(f, 'r').read())
if len(disk) < 140*1024:
print "Disk %s truncated (%d bytes)" % (len(disk))
length = len(disk)
if length < 140*1024:
print "Disk %s truncated (%d bytes)" % length
continue
if length % 256 != 0:
print "Disk length %d does not align to sector boundary" % length
continue
boot1 = disk[:256]
sha1 = hashlib.sha1(disk).hexdigest()