From b25c8d9a5ac34c96b84533efe6da609598796b40 Mon Sep 17 00:00:00 2001 From: Matt Palmer Date: Thu, 23 Apr 2020 12:36:15 +1000 Subject: [PATCH] Add some more generic error messages These are almost all taken from error messages that are specific to one particular module, and turned into generic errors that can be used for any module. It seemed like a better idea to provide generic messages than to encourage infinite proliferation of error codes (which would probably end up blowing the 255 value threshold sooner or later). It doesn't seem necessary to provide module-specific error messages for things like "Invalid filesize", since users should already know what sort of file they're asking to be parsed. --- include/types.h | 4 ++++ src/shared.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/include/types.h b/include/types.h index 47eff8f28..8827c9056 100644 --- a/include/types.h +++ b/include/types.h @@ -534,6 +534,10 @@ typedef enum parser_rc PARSER_TOKEN_LENGTH = -35, PARSER_INSUFFICIENT_ENTROPY = -36, PARSER_PKZIP_CT_UNMATCHED = -37, + PARSER_KEY_SIZE = -38, + PARSER_BLOCK_SIZE = -39, + PARSER_CIPHER = -40, + PARSER_FILE_SIZE = -41, PARSER_UNKNOWN_ERROR = -255 } parser_rc_t; diff --git a/src/shared.c b/src/shared.c index 05387f5e6..fd3de496f 100644 --- a/src/shared.c +++ b/src/shared.c @@ -53,6 +53,10 @@ static const char *PA_034 = "Token encoding exception"; static const char *PA_035 = "Token length exception"; static const char *PA_036 = "Insufficient entropy exception"; static const char *PA_037 = "Hash contains unsupported compression type for current mode"; +static const char *PA_038 = "Invalid key size"; +static const char *PA_039 = "Invalid block size"; +static const char *PA_040 = "Invalid or unsupported cipher"; +static const char *PA_041 = "Invalid filesize"; static const char *PA_255 = "Unknown error"; static const char *OPTI_STR_OPTIMIZED_KERNEL = "Optimized-Kernel"; @@ -1002,6 +1006,10 @@ const char *strparser (const u32 parser_status) case PARSER_TOKEN_LENGTH: return PA_035; case PARSER_INSUFFICIENT_ENTROPY: return PA_036; case PARSER_PKZIP_CT_UNMATCHED: return PA_037; + case PARSER_KEY_SIZE: return PA_038; + case PARSER_BLOCK_SIZE: return PA_039; + case PARSER_CIPHER: return PA_040; + case PARSER_FILE_SIZE: return PA_041; } return PA_255;