mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-28 22:36:24 +01:00
Fix fdisk(8) to create 2TB partitions on disks larger than 2TB, rather than
only being able to create 1TB partitions: o) Use an unsigned 32-bit quantity to store the number of disk sectors. o) Detect overflow of said 32-bit quantity and clamp to 2^32. o) Rather than returning the disk sector count from get_params, return 0 on success, since its return value is only ever compared to -1 to detect failure. This would cause returning 2^32 sectors to be interpreted as an error. Reviewed by: bde ("good for a quick fix")
This commit is contained in:
parent
168d70db8a
commit
c69a7a718d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=258686
@ -75,7 +75,8 @@ static int secsize = 0; /* the sensed sector size */
|
||||
|
||||
static char *disk;
|
||||
|
||||
static int cyls, sectors, heads, cylsecs, disksecs;
|
||||
static int cyls, sectors, heads, cylsecs;
|
||||
static u_int32_t disksecs;
|
||||
|
||||
struct mboot {
|
||||
unsigned char *bootinst; /* boot code */
|
||||
@ -873,10 +874,13 @@ get_params()
|
||||
o = g_mediasize(fd);
|
||||
if (o < 0)
|
||||
return (-1);
|
||||
disksecs = o / u;
|
||||
if (o / u <= NO_DISK_SECTORS)
|
||||
disksecs = o / u;
|
||||
else
|
||||
disksecs = NO_DISK_SECTORS;
|
||||
cyls = dos_cyls = o / (u * dos_heads * dos_sectors);
|
||||
|
||||
return (disksecs);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user