Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[tftp] Prevent potential division by zero
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 18, 2018
1 parent c160c9d commit b11ae1d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/net/udp/tftp.c
Expand Up @@ -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: "
Expand Down

0 comments on commit b11ae1d

Please sign in to comment.