[tftp] Prevent potential division by zero

Signed-off-by: Michael Brown <mcb30@ipxe.org>
pull/71/head
Michael Brown 2018-03-18 17:43:11 +02:00
parent c160c9dfc0
commit b11ae1d91b
1 changed files with 2 additions and 0 deletions

View File

@ -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
* trailing zero-length block, which must be included.
*/
if ( tftp->blksize == 0 )
return -EINVAL;
num_blocks = ( ( filesize / tftp->blksize ) + 1 );
if ( ( rc = bitmap_resize ( &tftp->bitmap, num_blocks ) ) != 0 ) {
DBGC ( tftp, "TFTP %p could not resize bitmap to %d blocks: "