Skip to content

Commit

Permalink
dx1elf2dfu: use intended padding value
Browse files Browse the repository at this point in the history
  • Loading branch information
majbthrd committed Nov 29, 2019
1 parent b37cf9d commit cc14926
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dx1elf2dfu/dx1elf2dfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,14 @@ static struct memory_blob *find_blob(uint32_t address, uint32_t count, struct me
}

addition = malloc(sizeof(struct memory_blob));
memset(addition, 0xFF, sizeof(struct memory_blob));

addition->data = malloc(count);
addition->address = address;
addition->count = count;
addition->next = current;

memset(addition->data, 0xFF, count); /* use a padding_value of 0xFF */

if (previous)
previous->next = addition;
else
Expand Down Expand Up @@ -564,9 +565,9 @@ int main(int argc, char *argv[])
stuff_size |= (uint32_t)binary[app_len_offset + 1] << 8;
stuff_size |= (uint32_t)binary[app_len_offset + 0] << 0;

if (stuff_size)
if ( stuff_size && (stuff_size != max_offset) )
{
printf("WARNING: overwriting 0x%x at 0x%x with length value (%d)\n", stuff_size, origin_addr + app_len_offset, max_offset);
printf("WARNING: overwriting 0x%x at 0x%x with length value (0x%x)\n", stuff_size, origin_addr + app_len_offset, max_offset);
}

/* store app length within application itself */
Expand All @@ -593,9 +594,9 @@ int main(int argc, char *argv[])
stuff_size |= (uint32_t)binary[app_crc_offset + 1] << 8;
stuff_size |= (uint32_t)binary[app_crc_offset + 0] << 0;

if (stuff_size)
if ( stuff_size && (stuff_size != span) )
{
printf("WARNING: overwriting 0x%x at 0x%x with CRC value (%d)\n", stuff_size, origin_addr + app_crc_offset, span);
printf("WARNING: overwriting 0x%x at 0x%x with CRC value (0x%x)\n", stuff_size, origin_addr + app_crc_offset, span);
}

/* store app CRC within application itself */
Expand Down

0 comments on commit cc14926

Please sign in to comment.