From 7d59d75eeeb586831c0645dbc5b700dfa9310941 Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Wed, 20 Apr 2016 09:03:17 +0200 Subject: [PATCH] fexc: Regroup code in script_decompile_bin() Move some lines so that the safeguards run (and exit, if needed) before the normal output of header information. Signed-off-by: Bernhard Nortmann --- script_bin.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/script_bin.c b/script_bin.c index 0eec7f5..ffe9051 100644 --- a/script_bin.c +++ b/script_bin.c @@ -315,17 +315,6 @@ int script_decompile_bin(void *bin, size_t bin_size, unsigned int i; struct script_bin_head *head = bin; - pr_info("%s: version: %u.%u.%u\n", filename, - head->version[0], head->version[1], head->version[2]); - pr_info("%s: size: %zu (%u sections)\n", filename, - bin_size, head->sections); - - if (head->sections > SCRIPT_BIN_SECTION_LIMIT) { - pr_err("Malformed data: too many sections (%u).\n", - head->sections); - return 0; - } - if ((head->version[0] > SCRIPT_BIN_VERSION_LIMIT) || (head->version[1] > SCRIPT_BIN_VERSION_LIMIT) || (head->version[2] > SCRIPT_BIN_VERSION_LIMIT)) { @@ -334,6 +323,17 @@ int script_decompile_bin(void *bin, size_t bin_size, return 0; } + if (head->sections > SCRIPT_BIN_SECTION_LIMIT) { + pr_err("Malformed data: too many sections (%u).\n", + head->sections); + return 0; + } + + pr_info("%s: version: %u.%u.%u\n", filename, + head->version[0], head->version[1], head->version[2]); + pr_info("%s: size: %zu (%u sections)\n", filename, + bin_size, head->sections); + /* TODO: SANITY: compare head.sections with bin_size */ for (i=0; i < head->sections; i++) { struct script_bin_section *section = &head->section[i];