summaryrefslogtreecommitdiffstats
path: root/sbin/i386
diff options
context:
space:
mode:
authorgibbs <gibbs@FreeBSD.org>1997-06-02 19:25:48 +0000
committergibbs <gibbs@FreeBSD.org>1997-06-02 19:25:48 +0000
commit9ad77f813d253002b177ffa0d670ff9d0af7d093 (patch)
treec633ff3571c22cb6bfe41d9b95a99d2bbeb4eeb9 /sbin/i386
parent4ee3b9173790a0b0b4bf502bfe54a09c20cf152c (diff)
downloadFreeBSD-src-9ad77f813d253002b177ffa0d670ff9d0af7d093.zip
FreeBSD-src-9ad77f813d253002b177ffa0d670ff9d0af7d093.tar.gz
Don't overflow when calculating the size in MB of a partition.
No more 241MB 4+ gig partitions for me!
Diffstat (limited to 'sbin/i386')
-rw-r--r--sbin/i386/fdisk/fdisk.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sbin/i386/fdisk/fdisk.c b/sbin/i386/fdisk/fdisk.c
index 6f759f8..8e3e267 100644
--- a/sbin/i386/fdisk/fdisk.c
+++ b/sbin/i386/fdisk/fdisk.c
@@ -429,17 +429,26 @@ static struct dos_partition mtpart = { 0 };
static void
print_part(int i)
{
-struct dos_partition *partp = ((struct dos_partition *) &mboot.parts) + i;
+ struct dos_partition *partp;
+ u_int64_t part_mb;
+ partp = ((struct dos_partition *) &mboot.parts) + i;
if (!bcmp(partp, &mtpart, sizeof (struct dos_partition))) {
printf("<UNUSED>\n");
return;
}
+ /*
+ * Be careful not to overflow.
+ */
+ part_mb = partp->dp_size;
+ part_mb *= secsize;
+ part_mb /= (1024 * 1024);
printf("sysid %d,(%s)\n", partp->dp_typ, get_type(partp->dp_typ));
- printf(" start %ld, size %ld (%ld Meg), flag %x\n",
+ printf(" start %ld, size %ld (%qd Meg), flag %x\n",
partp->dp_start,
- partp->dp_size, partp->dp_size * secsize / (1024 * 1024),
+ partp->dp_size,
+ part_mb,
partp->dp_flag);
printf("\tbeg: cyl %d/ sector %d/ head %d;\n\tend: cyl %d/ sector %d/ head %d\n"
,DPCYL(partp->dp_scyl, partp->dp_ssect)
OpenPOWER on IntegriCloud