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

Loading…
Cancel
Save