summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2018-03-18 16:43:11 +0100
committerMichael Brown2018-03-18 16:43:11 +0100
commitb11ae1d91b32c7d0d52a0fc35a37b5e2f57a0f79 (patch)
treed055dbb9adbc68f35645bfa4d5c1c01fe8600825
parent[lacp] Fix debug message to match documentation (diff)
downloadipxe-b11ae1d91b32c7d0d52a0fc35a37b5e2f57a0f79.tar.gz
ipxe-b11ae1d91b32c7d0d52a0fc35a37b5e2f57a0f79.tar.xz
ipxe-b11ae1d91b32c7d0d52a0fc35a37b5e2f57a0f79.zip
[tftp] Prevent potential division by zero
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/net/udp/tftp.c2
1 files changed, 2 insertions, 0 deletions
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: "