Fix integer overflow in "camcontrol format"

Reported by:	Coverity
CID:		1011426
MFC after:	1 week
Sponsored by:	Spectra Logic Corp
This commit is contained in:
Alan Somers 2017-05-31 14:59:03 +00:00
parent 43a251d687
commit 8a7fc69049

View File

@ -6221,15 +6221,15 @@ scsiformat(struct cam_device *device, int argc, char **argv,
if ((scsi_get_sks(sense, ccb->csio.sense_len -
ccb->csio.sense_resid, sks) == 0)
&& (quiet == 0)) {
int val;
uint32_t val;
u_int64_t percentage;
val = scsi_2btoul(&sks[1]);
percentage = 10000 * val;
percentage = 10000ull * val;
fprintf(stdout,
"\rFormatting: %ju.%02u %% "
"(%d/%d) done",
"(%u/%d) done",
(uintmax_t)(percentage /
(0x10000 * 100)),
(unsigned)((percentage /