diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/format/elf/elf.c | 6 | ||||
-rw-r--r-- | src/format/executable.c | 12 | ||||
-rw-r--r-- | src/glibext/gbinportion.c | 34 | ||||
-rw-r--r-- | src/glibext/gbinportion.h | 3 |
4 files changed, 52 insertions, 3 deletions
diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c index 1254e52..1ca81be 100644 --- a/src/format/elf/elf.c +++ b/src/format/elf/elf.c @@ -269,7 +269,7 @@ GBinFormat *g_elf_format_new(GBinContent *content, GExeFormat *parent, GtkStatus if (ELF_HDR(result, result->header, e_phentsize) != ELF_SIZEOF_PHDR(result)) { - log_variadic_message(LMT_BAD_BINARY, _("Corrupted program header size (%hu); fixed ! -- replacing 0x%04hx by 0x%04hx at offset 0x%x"), + log_variadic_message(LMT_BAD_BINARY, _("Corrupted program header size (%hu); fixed! -- replacing 0x%04hx by 0x%04hx at offset 0x%x"), ELF_HDR(result, result->header, e_phentsize), ELF_HDR(result, result->header, e_phentsize), ELF_SIZEOF_PHDR(result), ELF_HDR_OFFSET_OF(result, e_phentsize)); @@ -278,7 +278,7 @@ GBinFormat *g_elf_format_new(GBinContent *content, GExeFormat *parent, GtkStatus if (ELF_HDR(result, result->header, e_shentsize) != ELF_SIZEOF_SHDR(result)) { - log_variadic_message(LMT_BAD_BINARY, _("Corrupted section header size (%hu); fixed ! -- replacing 0x%04hx by 0x%04hx at offset 0x%x"), + log_variadic_message(LMT_BAD_BINARY, _("Corrupted section header size (%hu); fixed! -- replacing 0x%04hx by 0x%04hx at offset 0x%x"), ELF_HDR(result, result->header, e_shentsize), ELF_HDR(result, result->header, e_shentsize), ELF_SIZEOF_SHDR(result), ELF_HDR_OFFSET_OF(result, e_shentsize)); @@ -289,7 +289,7 @@ GBinFormat *g_elf_format_new(GBinContent *content, GExeFormat *parent, GtkStatus /* if ((ELF_HDR(result, result->header, e_shnum) * ELF_HDR(result, result->header, e_shentsize)) >= length) { - log_variadic_message(LMT_BAD_BINARY, ("Suspicious section table (bigger than the binary !) ; reset ! -- replacing 0x%04hx by 0x%04hx at offset 0x%x"), + log_variadic_message(LMT_BAD_BINARY, ("Suspicious section table (bigger than the binary !) ; reset! -- replacing 0x%04hx by 0x%04hx at offset 0x%x"), ELF_HDR(result, result->header, e_shnum), 0, ELF_HDR_OFFSET_OF(result, e_shnum)); ELF_HDR_SET(result, result->header, e_shnum, 0); diff --git a/src/format/executable.c b/src/format/executable.c index fe3448d..f121f5b 100644 --- a/src/format/executable.c +++ b/src/format/executable.c @@ -30,6 +30,7 @@ #include "executable-int.h" #include "format.h" +#include "../gui/panels/log.h" @@ -340,6 +341,17 @@ bool g_executable_format_complete_loading(GExeFormat *format, GtkStatusStack *st void g_exe_format_include_portion(GExeFormat *format, GBinPortion *portion) { + phys_t max; /* Position hors limite */ + bool truncated; /* Modification faite ? */ + + max = g_binary_content_compute_size(G_BIN_FORMAT(format)->content); + + truncated = g_binary_portion_limit_range(portion, max); + + if (truncated) + log_variadic_message(LMT_BAD_BINARY, _("Truncated binary portion '%s' to fit the binary content size!"), + g_binary_portion_get_desc(portion)); + g_mutex_lock(&format->mutex); g_binary_portion_include(format->portions, portion); diff --git a/src/glibext/gbinportion.c b/src/glibext/gbinportion.c index b8e3ed7..731cd08 100644 --- a/src/glibext/gbinportion.c +++ b/src/glibext/gbinportion.c @@ -485,6 +485,40 @@ const mrange_t *g_binary_portion_get_range(const GBinPortion *portion) } +/****************************************************************************** +* * +* Paramètres : portion = description de partie à mettre à jour. * +* max = première position physique hors limite. * +* * +* Description : Assure qu'une portion ne dépasse pas une position donnée. * +* * +* Retour : true si la portion a été modifiée, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_binary_portion_limit_range(GBinPortion *portion, phys_t max) +{ + bool result; /* Bilan à retourner */ + vmpa2t end; /* Limite actuelle de portion */ + const vmpa2t *start; /* Position de départ */ + + compute_mrange_end_addr(&portion->range, &end); + + result = get_phy_addr(&end) > max; + + if (result) + { + start = get_mrange_addr(&portion->range); + set_mrange_length(&portion->range, max - get_phy_addr(start)); + + } + + return result; + +} + /****************************************************************************** * * diff --git a/src/glibext/gbinportion.h b/src/glibext/gbinportion.h index 9f22e3d..14a6960 100644 --- a/src/glibext/gbinportion.h +++ b/src/glibext/gbinportion.h @@ -99,6 +99,9 @@ const char *g_binary_portion_get_desc(const GBinPortion *); /* Fournit l'emplacement d'une partie de code binaire. */ const mrange_t *g_binary_portion_get_range(const GBinPortion *); +/* Assure qu'une portion ne dépasse pas une position donnée. */ +bool g_binary_portion_limit_range(GBinPortion *, phys_t); + /* Définit la nature de la portion en terme d'originalité. */ void g_binary_portion_mark_as_continued(GBinPortion *, bool); |