mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-06 16:40:47 +00:00
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
917fa2a3e9
commit
1723a6e523
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=327617
|
@ -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 a new issue