Browse Source

[tftp] Prevent potential division by zero

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 6 years ago
parent
commit
b11ae1d91b
1 changed files with 2 additions and 0 deletions
  1. 2
    0
      src/net/udp/tftp.c

+ 2
- 0
src/net/udp/tftp.c View File

@@ -279,6 +279,8 @@ static int tftp_presize ( struct tftp_request *tftp, size_t filesize ) {
279 279
 	 * length is an exact multiple of the blocksize will have a
280 280
 	 * trailing zero-length block, which must be included.
281 281
 	 */
282
+	if ( tftp->blksize == 0 )
283
+		return -EINVAL;
282 284
 	num_blocks = ( ( filesize / tftp->blksize ) + 1 );
283 285
 	if ( ( rc = bitmap_resize ( &tftp->bitmap, num_blocks ) ) != 0 ) {
284 286
 		DBGC ( tftp, "TFTP %p could not resize bitmap to %d blocks: "

Loading…
Cancel
Save