libpayload: Fix an integer overflow in USB mass storage
Change-Id: I3d618497016478ea727c520e866d27dbc3ebf9af Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: http://review.coreboot.org/1070 Reviewed-by: Mathias Krause <minipli@googlemail.com> Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
parent
0421dc84df
commit
c43e736c0c
|
@ -360,6 +360,9 @@ read_capacity (usbdev_t *dev)
|
||||||
}
|
}
|
||||||
printf (" %d %d-byte sectors (%d MB)\n", MSC_INST (dev)->numblocks,
|
printf (" %d %d-byte sectors (%d MB)\n", MSC_INST (dev)->numblocks,
|
||||||
MSC_INST (dev)->blocksize,
|
MSC_INST (dev)->blocksize,
|
||||||
|
/* round down high block counts to avoid integer overflow */
|
||||||
|
MSC_INST (dev)->numblocks > 1000000
|
||||||
|
? (MSC_INST (dev)->numblocks / 1000) * MSC_INST (dev)->blocksize / 1000 :
|
||||||
MSC_INST (dev)->numblocks * MSC_INST (dev)->blocksize / 1000 / 1000);
|
MSC_INST (dev)->numblocks * MSC_INST (dev)->blocksize / 1000 / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue