From a71320ec9d25f07e9ba312bc2645901f52bf23d9 Mon Sep 17 00:00:00 2001 From: philsmd Date: Sat, 9 Jul 2022 11:57:55 +0200 Subject: [PATCH] improved hash sanity checks for -m 26200 = OpenEdge --- src/modules/module_26200.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/modules/module_26200.c b/src/modules/module_26200.c index c7cc91cae..fe3c9bb82 100644 --- a/src/modules/module_26200.c +++ b/src/modules/module_26200.c @@ -109,7 +109,27 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const u8 *hash_pos = (u8 *) token.buf[0]; const u32 hash_len = token.len[0]; - memcpy ((u8 *)digest, hash_pos, hash_len); + /* + * Check encoding: + */ + + for (u32 i = 0; i < hash_len; i++) + { + // chars used (alphabet): + // ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz + + const u8 c = hash_pos[i]; + + if ( c < 'A') return (PARSER_HASH_ENCODING); + if (c > 'Z' && c < 'a') return (PARSER_HASH_ENCODING); + if (c > 'z' ) return (PARSER_HASH_ENCODING); + } + + /* + * digest: + */ + + memcpy ((u8 *) digest, hash_pos, hash_len); return (PARSER_OK); }