Skip to content

Commit

Permalink
Allow empty sections as found in the FEX files of Ippo q8h v1.2 and F…
Browse files Browse the repository at this point in the history
…SL S8

Signed-off-by: Henrik Nordstrom <[email protected]>
  • Loading branch information
rma-x authored and hno committed Oct 28, 2014
1 parent dfece17 commit d532927
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions script_bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ size_t script_bin_size(struct script *script,
}
words += WORDS(size);
}
if (c>0) {
*sections += 1;
*entries += c;
}
*sections += 1;
*entries += c;
}

bin_size = sizeof(struct script_bin_head) +
Expand Down Expand Up @@ -133,9 +131,6 @@ int script_generate_bin(void *bin, size_t UNUSED(bin_size),
size_t c = 0;
s = container_of(ls, struct script_section, sections);

/* skip empty sections */
if (list_empty(&s->entries))
continue;
memcpy(section->name, s->name, strlen(s->name));
section->offset = ((void*)entry-bin)>>2;

Expand Down Expand Up @@ -227,7 +222,7 @@ static int decompile_section(void *bin, size_t bin_size,

size = bin_size - 4 * section->offset;

if ((section->length <= 0) ||
if ((section->length < 0) ||
(section->length > (size / (int)sizeof(struct script_bin_entry)))) {
pr_err("Malformed data: invalid section length: %d\n",
section->length);
Expand Down

0 comments on commit d532927

Please sign in to comment.