]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[tftp] Prevent potential division by zero
authorMichael Brown <mcb30@ipxe.org>
Sun, 18 Mar 2018 15:43:11 +0000 (17:43 +0200)
committerMichael Brown <mcb30@ipxe.org>
Sun, 18 Mar 2018 15:43:11 +0000 (17:43 +0200)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/udp/tftp.c

index 4255472ee3e5526f073c1bc8bc122829f5736317..6ce27497c224e982fa73f0af9aaa5c205c97dad0 100644 (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: "