summaryrefslogtreecommitdiff
path: root/rbutil
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-08-22 17:49:50 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-08-22 17:49:50 +0200
commita2d4a4a560a3405812871017a0f08fdec2b07e14 (patch)
tree11f7cc96259ad82f68ea28425566913bfba231b3 /rbutil
parentacaedfdb89dc73e64559791e91239942c27a86c6 (diff)
downloadrockbox-a2d4a4a560a3405812871017a0f08fdec2b07e14.tar.gz
rockbox-a2d4a4a560a3405812871017a0f08fdec2b07e14.zip
mkimxboot: fix crash
I was too aggressive when converting reads to standard reads, this one is memory based and not file based Change-Id: Ibe7162894cc44cbd79f56cafe7136bda0f76bcdc
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/mkimxboot/mkimxboot.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/rbutil/mkimxboot/mkimxboot.c b/rbutil/mkimxboot/mkimxboot.c
index c0d91854d7..12b029ec9d 100644
--- a/rbutil/mkimxboot/mkimxboot.c
+++ b/rbutil/mkimxboot/mkimxboot.c
@@ -604,6 +604,18 @@ struct elf_user_t
604 size_t sz; 604 size_t sz;
605}; 605};
606 606
607static bool elf_read(void *user, uint32_t addr, void *buf, size_t count)
608{
609 struct elf_user_t *u = user;
610 if(addr + count <= u->sz)
611 {
612 memcpy(buf, u->buf + addr, count);
613 return true;
614 }
615 else
616 return false;
617}
618
607/* Load a rockbox firwmare from a buffer. Data is copied. Assume firmware is 619/* Load a rockbox firwmare from a buffer. Data is copied. Assume firmware is
608 * using ELF format. */ 620 * using ELF format. */
609static enum imx_error_t rb_fw_load_buf_elf(struct rb_fw_t *fw, uint8_t *buf, 621static enum imx_error_t rb_fw_load_buf_elf(struct rb_fw_t *fw, uint8_t *buf,
@@ -614,7 +626,7 @@ static enum imx_error_t rb_fw_load_buf_elf(struct rb_fw_t *fw, uint8_t *buf,
614 user.buf = buf; 626 user.buf = buf;
615 user.sz = sz; 627 user.sz = sz;
616 elf_init(&elf); 628 elf_init(&elf);
617 if(!elf_read_file(&elf, elf_std_read, generic_std_printf, &user)) 629 if(!elf_read_file(&elf, elf_read, generic_std_printf, &user))
618 { 630 {
619 elf_release(&elf); 631 elf_release(&elf);
620 printf("[ERR] Error parsing ELF file\n"); 632 printf("[ERR] Error parsing ELF file\n");