From: Michael Brown Date: Sun, 18 Mar 2018 15:43:11 +0000 (+0200) Subject: [tftp] Prevent potential division by zero X-Git-Tag: v1.20.1~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b11ae1d91b32c7d0d52a0fc35a37b5e2f57a0f79;p=thirdparty%2Fipxe.git [tftp] Prevent potential division by zero Signed-off-by: Michael Brown --- diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c index 4255472ee..6ce27497c 100644 --- a/src/net/udp/tftp.c +++ b/src/net/udp/tftp.c @@ -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: "