소스 검색

[tftp] Prevent potential division by zero

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 년 전
부모
커밋
b11ae1d91b
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. 2
    0
      src/net/udp/tftp.c

+ 2
- 0
src/net/udp/tftp.c 파일 보기

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…
취소
저장