mirror of
https://github.com/ipxe/ipxe
synced 2025-12-14 07:50:43 +03:00
[tftp] Prevent potential division by zero
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -279,6 +279,8 @@ static int tftp_presize ( struct tftp_request *tftp, size_t filesize ) {
|
|||||||
* length is an exact multiple of the blocksize will have a
|
* length is an exact multiple of the blocksize will have a
|
||||||
* trailing zero-length block, which must be included.
|
* trailing zero-length block, which must be included.
|
||||||
*/
|
*/
|
||||||
|
if ( tftp->blksize == 0 )
|
||||||
|
return -EINVAL;
|
||||||
num_blocks = ( ( filesize / tftp->blksize ) + 1 );
|
num_blocks = ( ( filesize / tftp->blksize ) + 1 );
|
||||||
if ( ( rc = bitmap_resize ( &tftp->bitmap, num_blocks ) ) != 0 ) {
|
if ( ( rc = bitmap_resize ( &tftp->bitmap, num_blocks ) ) != 0 ) {
|
||||||
DBGC ( tftp, "TFTP %p could not resize bitmap to %d blocks: "
|
DBGC ( tftp, "TFTP %p could not resize bitmap to %d blocks: "
|
||||||
|
|||||||
Reference in New Issue
Block a user