From a75b2fbdbe340fdef03b80e9fc826197d2bc1f9b Mon Sep 17 00:00:00 2001 From: Ophelia Beatrice de Sica Date: Thu, 19 Oct 2023 15:31:54 +0200 Subject: [PATCH 1/2] Remove exit() from libpe --- lib/libpe/hashes.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libpe/hashes.c b/lib/libpe/hashes.c index abcc1c9..51918be 100644 --- a/lib/libpe/hashes.c +++ b/lib/libpe/hashes.c @@ -21,6 +21,7 @@ #include "libpe/hashes.h" +#include "error.h" #include "libpe/pe.h" #include "libfuzzy/fuzzy.h" #include "libpe/ordlookup.h" @@ -139,9 +140,6 @@ static pe_err_e get_headers_optional_hash(pe_ctx_t *ctx, pe_hash_t *output) { const IMAGE_OPTIONAL_HEADER *sample = pe_optional(ctx); switch (sample->type) { - default: - // TODO(jweyrich): handle unknown type. - exit(1); case MAGIC_ROM: { const unsigned char *data = (const unsigned char *)sample->_rom; @@ -160,6 +158,8 @@ static pe_err_e get_headers_optional_hash(pe_ctx_t *ctx, pe_hash_t *output) { const uint64_t data_size = sizeof(IMAGE_OPTIONAL_HEADER_64); return get_hashes(output, "IMAGE_OPTIONAL_HEADER_64", data, data_size); } + default: + return LIBPE_E_UNSUPPORTED_IMAGE; } } From fdd5671f2a71c252f90a9f5fa6b05bdbce98a707 Mon Sep 17 00:00:00 2001 From: Ophelia Beatrice de Sica Date: Thu, 19 Oct 2023 15:47:10 +0200 Subject: [PATCH 2/2] Fix error.h import in hashes.c --- lib/libpe/hashes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libpe/hashes.c b/lib/libpe/hashes.c index 51918be..dd894a0 100644 --- a/lib/libpe/hashes.c +++ b/lib/libpe/hashes.c @@ -21,7 +21,7 @@ #include "libpe/hashes.h" -#include "error.h" +#include "libpe/error.h" #include "libpe/pe.h" #include "libfuzzy/fuzzy.h" #include "libpe/ordlookup.h"