From 2f88eabe572f0a007d64d2d989e7e8a0ebe3303e Mon Sep 17 00:00:00 2001 From: rdbo Date: Sat, 6 Apr 2024 08:56:10 -0300 Subject: [PATCH] fixed issue in signature scan --- src/common/scan.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common/scan.c b/src/common/scan.c index 0eb39927..2d0dd152 100644 --- a/src/common/scan.c +++ b/src/common/scan.c @@ -185,7 +185,7 @@ sig_to_pattern(lm_string_t signature, lm_byte_t **pattern_out, lm_char_t **mask_ return LM_FALSE; } - if (alloc = realloc(mask, (bytecount + 1) * sizeof(lm_char_t))) { + if (alloc = realloc(mask, (bytecount + 2) * sizeof(lm_char_t))) { mask = (lm_char_t *)alloc; } else { free(mask); @@ -197,6 +197,7 @@ sig_to_pattern(lm_string_t signature, lm_byte_t **pattern_out, lm_char_t **mask_ if (pattern[bytecount] == 0 && ptr == endptr) { endptr = strchr(&ptr[1], ' '); mask[bytecount] = '?'; + mask[bytecount + 1] = '\0'; } else { mask[bytecount] = 'x'; } @@ -225,6 +226,14 @@ LM_SigScan(lm_string_t signature, if (!sig_to_pattern(signature, &pattern, &mask)) return match; + /* TODO: Delete */ + printf("Parsed signature %s into:\n", signature); + for (size_t i = 0; i < strlen(mask); ++i) { + printf("%hhx", (unsigned char)pattern[i]); + } + printf("\n"); + printf("%s\n", mask); + match = LM_PatternScan(pattern, mask, address, scansize); free(pattern);