Skip to content

Commit

Permalink
Support unaligned boot image file
Browse files Browse the repository at this point in the history
Fix #7733
  • Loading branch information
topjohnwu committed Oct 6, 2024
1 parent 44fb7db commit 7188de1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions native/src/boot/bootimg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ static const char *vendor_ramdisk_type(int type) {
}

#define assert_off() \
if ((base_addr + off) > (map.buf() + map.sz())) { \
if ((base_addr + off) > (map.buf() + map_end)) { \
fprintf(stderr, "Corrupted boot image!\n"); \
return false; \
}
Expand Down Expand Up @@ -395,6 +395,7 @@ bool boot_img::parse_image(const uint8_t *p, format_t type) {

hdr->print();

size_t map_end = align_to(map.sz(), getpagesize());
size_t off = hdr->hdr_space();
get_block(kernel);
get_block(ramdisk);
Expand All @@ -408,7 +409,7 @@ bool boot_img::parse_image(const uint8_t *p, format_t type) {

payload = byte_view(base_addr, off);
auto tail_addr = base_addr + off;
tail = byte_view(tail_addr, map.buf() + map.sz() - tail_addr);
tail = byte_view(tail_addr, map.buf() + map_end - tail_addr);

if (auto size = hdr->kernel_size()) {
if (int dtb_off = find_dtb_offset(kernel, size); dtb_off > 0) {
Expand Down

0 comments on commit 7188de1

Please sign in to comment.