static int omapimage_verify_header(unsigned char *ptr, int image_size, struct mkimage_params *params) { struct ch_toc *toc = (struct ch_toc *)ptr; struct gp_header *gph = (struct gp_header *)(ptr+OMAP_CH_HDR_SIZE); uint32_t offset, size; while (toc->section_offset != 0xffffffff && toc->section_size != 0xffffffff) { offset = toc->section_offset; size = toc->section_size; if (!offset || !size) return -1; if (offset >= OMAP_CH_HDR_SIZE || offset+size >= OMAP_CH_HDR_SIZE) return -1; toc++; } if (!valid_gph_size(gph->size)) return -1; if (!valid_gph_load_addr(gph->load_addr)) return -1; return 0; }
static void omapimage_print_header(const void *ptr) { const struct ch_toc *toc = (struct ch_toc *)ptr; const struct gp_header *gph = (struct gp_header *)(ptr+OMAP_CH_HDR_SIZE); uint32_t offset, size, gph_size, gph_load_addr; while (toc->section_offset != 0xffffffff && toc->section_size != 0xffffffff) { if (do_swap32) { offset = omapimage_swap32(toc->section_offset); size = omapimage_swap32(toc->section_size); } else { offset = toc->section_offset; size = toc->section_size; } if (offset >= OMAP_CH_HDR_SIZE || offset+size >= OMAP_CH_HDR_SIZE) exit(EXIT_FAILURE); printf("Section %s offset %x length %x\n", toc->section_name, toc->section_offset, toc->section_size); omapimage_print_section((struct ch_settings *)(ptr+offset)); toc++; } if (do_swap32) { gph_size = omapimage_swap32(gph->size); gph_load_addr = omapimage_swap32(gph->load_addr); } else { gph_size = gph->size; gph_load_addr = gph->load_addr; } if (!valid_gph_size(gph_size)) { fprintf(stderr, "Error: invalid image size %x\n", gph_size); exit(EXIT_FAILURE); } if (!valid_gph_load_addr(gph_load_addr)) { fprintf(stderr, "Error: invalid image load address %x\n", gph_load_addr); exit(EXIT_FAILURE); } printf("GP Header: Size %x LoadAddr %x\n", gph_size, gph_load_addr); }