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.
This commit is contained in:
parent
fc03710c55
commit
8d3105e8d4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=73573
@ -1331,7 +1331,7 @@ checklabel(lp)
|
|||||||
register struct partition *pp;
|
register struct partition *pp;
|
||||||
int i, errors = 0;
|
int i, errors = 0;
|
||||||
char part;
|
char part;
|
||||||
unsigned long total_size,total_percent,current_offset;
|
unsigned long total_size, total_percent, current_offset;
|
||||||
int seen_default_offset;
|
int seen_default_offset;
|
||||||
int hog_part;
|
int hog_part;
|
||||||
int j;
|
int j;
|
||||||
@ -1394,7 +1394,7 @@ checklabel(lp)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char *type;
|
char *type;
|
||||||
unsigned long size;
|
off_t size;
|
||||||
|
|
||||||
size = pp->p_size;
|
size = pp->p_size;
|
||||||
switch (part_size_type[i]) {
|
switch (part_size_type[i]) {
|
||||||
@ -1403,15 +1403,15 @@ checklabel(lp)
|
|||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
case 'K':
|
case 'K':
|
||||||
size *= 1024UL;
|
size *= 1024ULL;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
case 'M':
|
case 'M':
|
||||||
size *= ((unsigned long) 1024*1024);
|
size *= 1024ULL * 1024ULL;
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'G':
|
case 'G':
|
||||||
size *= ((unsigned long) 1024*1024*1024);
|
size *= 1024ULL * 1024ULL * 1024ULL;
|
||||||
break;
|
break;
|
||||||
case '\0':
|
case '\0':
|
||||||
break;
|
break;
|
||||||
|
@ -1331,7 +1331,7 @@ checklabel(lp)
|
|||||||
register struct partition *pp;
|
register struct partition *pp;
|
||||||
int i, errors = 0;
|
int i, errors = 0;
|
||||||
char part;
|
char part;
|
||||||
unsigned long total_size,total_percent,current_offset;
|
unsigned long total_size, total_percent, current_offset;
|
||||||
int seen_default_offset;
|
int seen_default_offset;
|
||||||
int hog_part;
|
int hog_part;
|
||||||
int j;
|
int j;
|
||||||
@ -1394,7 +1394,7 @@ checklabel(lp)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char *type;
|
char *type;
|
||||||
unsigned long size;
|
off_t size;
|
||||||
|
|
||||||
size = pp->p_size;
|
size = pp->p_size;
|
||||||
switch (part_size_type[i]) {
|
switch (part_size_type[i]) {
|
||||||
@ -1403,15 +1403,15 @@ checklabel(lp)
|
|||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
case 'K':
|
case 'K':
|
||||||
size *= 1024UL;
|
size *= 1024ULL;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
case 'M':
|
case 'M':
|
||||||
size *= ((unsigned long) 1024*1024);
|
size *= 1024ULL * 1024ULL;
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
case 'G':
|
case 'G':
|
||||||
size *= ((unsigned long) 1024*1024*1024);
|
size *= 1024ULL * 1024ULL * 1024ULL;
|
||||||
break;
|
break;
|
||||||
case '\0':
|
case '\0':
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user