Check DTB image size for boot image header version 2 and above

DTB in boot image is mandatory for boot image header version 2
and above. mkbootimg.py must check the size of the DTB image passed
to it and throw an error if the image is empty.

Test: build with no DTB files in BOARD_PREBUILT_DTBIMAGE_DIR
Bug: 133006443
Change-Id: I478fcdb8e77957848a93027e695fcb238c544d62
This commit is contained in:
Hridya Valsaraju 2019-05-17 16:43:25 -07:00
parent 56311071fe
commit 96fd8874ef
1 changed files with 4 additions and 0 deletions

View File

@ -113,6 +113,10 @@ def write_header(args):
args.output.write(pack('I', BOOT_IMAGE_HEADER_V2_SIZE))
if args.header_version > 1:
if filesize(args.dtb) == 0:
raise ValueError("DTB image must not be empty.")
args.output.write(pack('I', filesize(args.dtb))) # size in bytes
args.output.write(pack('Q', args.base + args.dtb_offset)) # dtb physical load address
pad_file(args.output, args.pagesize)