summaryrefslogtreecommitdiffstats
path: root/rbutil/mkimxboot
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/mkimxboot
parentacaedfdb89dc73e64559791e91239942c27a86c6 (diff)
downloadrockbox-a2d4a4a560a3405812871017a0f08fdec2b07e14.tar.gz
rockbox-a2d4a4a560a3405812871017a0f08fdec2b07e14.tar.bz2
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/mkimxboot')
-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
size_t sz;
};
+static bool elf_read(void *user, uint32_t addr, void *buf, size_t count)
+{
+ struct elf_user_t *u = user;
+ if(addr + count <= u->sz)
+ {
+ memcpy(buf, u->buf + addr, count);
+ return true;
+ }
+ else
+ return false;
+}
+
/* Load a rockbox firwmare from a buffer. Data is copied. Assume firmware is
* using ELF format. */
static 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,
user.buf = buf;
user.sz = sz;
elf_init(&elf);
- if(!elf_read_file(&elf, elf_std_read, generic_std_printf, &user))
+ if(!elf_read_file(&elf, elf_read, generic_std_printf, &user))
{
elf_release(&elf);
printf("[ERR] Error parsing ELF file\n");