From b11ae1d91b32c7d0d52a0fc35a37b5e2f57a0f79 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sun, 18 Mar 2018 17:43:11 +0200 Subject: [tftp] Prevent potential division by zero Signed-off-by: Michael Brown --- src/net/udp/tftp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c index 4255472e..6ce27497 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: " -- cgit v1.2.3-55-g7522