aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2001-03-05 03:39:57 +0000
committerWarner Losh <imp@FreeBSD.org>2001-03-05 03:39:57 +0000
commit8d3105e8d43022acb1ba9422b2531bd6d29d329c (patch)
treeaaf55f68a06d7d2513439eb7b92f2e5552422d11 /sbin
parentfc03710c559bbc8a344c7cf9ccb68b6800c45d86 (diff)
downloadsrc-8d3105e8d43022acb1ba9422b2531bd6d29d329c.tar.gz
src-8d3105e8d43022acb1ba9422b2531bd6d29d329c.zip
First attempt to not overflow in disk space calculations. Use off_t
for the size variable used to calculate the size of the partition. Also use ULL suffix for constants to ensure that we use 64 bit math.
Notes
Notes: svn path=/head/; revision=73573
Diffstat (limited to 'sbin')
-rw-r--r--sbin/bsdlabel/bsdlabel.c10
-rw-r--r--sbin/disklabel/disklabel.c10
2 files changed, 10 insertions, 10 deletions
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
index cec9cc0191c6..26c2ee3bfc28 100644
--- a/sbin/bsdlabel/bsdlabel.c
+++ b/sbin/bsdlabel/bsdlabel.c
@@ -1331,7 +1331,7 @@ checklabel(lp)
register struct partition *pp;
int i, errors = 0;
char part;
- unsigned long total_size,total_percent,current_offset;
+ unsigned long total_size, total_percent, current_offset;
int seen_default_offset;
int hog_part;
int j;
@@ -1394,7 +1394,7 @@ checklabel(lp)
}
} else {
char *type;
- unsigned long size;
+ off_t size;
size = pp->p_size;
switch (part_size_type[i]) {
@@ -1403,15 +1403,15 @@ checklabel(lp)
break;
case 'k':
case 'K':
- size *= 1024UL;
+ size *= 1024ULL;
break;
case 'm':
case 'M':
- size *= ((unsigned long) 1024*1024);
+ size *= 1024ULL * 1024ULL;
break;
case 'g':
case 'G':
- size *= ((unsigned long) 1024*1024*1024);
+ size *= 1024ULL * 1024ULL * 1024ULL;
break;
case '\0':
break;
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index cec9cc0191c6..26c2ee3bfc28 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1331,7 +1331,7 @@ checklabel(lp)
register struct partition *pp;
int i, errors = 0;
char part;
- unsigned long total_size,total_percent,current_offset;
+ unsigned long total_size, total_percent, current_offset;
int seen_default_offset;
int hog_part;
int j;
@@ -1394,7 +1394,7 @@ checklabel(lp)
}
} else {
char *type;
- unsigned long size;
+ off_t size;
size = pp->p_size;
switch (part_size_type[i]) {
@@ -1403,15 +1403,15 @@ checklabel(lp)
break;
case 'k':
case 'K':
- size *= 1024UL;
+ size *= 1024ULL;
break;
case 'm':
case 'M':
- size *= ((unsigned long) 1024*1024);
+ size *= 1024ULL * 1024ULL;
break;
case 'g':
case 'G':
- size *= ((unsigned long) 1024*1024*1024);
+ size *= 1024ULL * 1024ULL * 1024ULL;
break;
case '\0':
break;