Sanity check media size and sector counts to ensure that we don't
produce negative sector numbers in the testing algorithm. CID: 1198994
This commit is contained in:
parent
0a7ff7d651
commit
ab687701c5
@ -407,9 +407,14 @@ speeddisk(int fd, off_t mediasize, u_int sectorsize)
|
||||
int bulk, i;
|
||||
off_t b0, b1, sectorcount, step;
|
||||
|
||||
/*
|
||||
* Drives smaller than 1MB produce negative sector numbers,
|
||||
* as do 2048 or fewer sectors.
|
||||
*/
|
||||
sectorcount = mediasize / sectorsize;
|
||||
if (sectorcount <= 0)
|
||||
return; /* Can't test devices with no sectors */
|
||||
if (mediasize < 1024 * 1024 || sectorcount < 2048)
|
||||
return;
|
||||
|
||||
|
||||
step = 1ULL << (flsll(sectorcount / (4 * 200)) - 1);
|
||||
if (step > 16384)
|
||||
|
Loading…
Reference in New Issue
Block a user