detect: parsing avoiding infinite loop

by comparing size_t to strlen result
Instead of uint16_t which would loop

Ticket: #5310
pull/7455/head
Philippe Antoine 4 years ago committed by Victor Julien
parent 875eb58fb0
commit ced96a8aad

@ -99,7 +99,7 @@ int DetectContentDataParse(const char *keyword, const char *contentstr,
char converted = 0; char converted = 0;
{ {
uint16_t i, x; size_t i, x;
uint8_t bin = 0; uint8_t bin = 0;
uint8_t escape = 0; uint8_t escape = 0;
uint8_t binstr[3] = ""; uint8_t binstr[3] = "";

@ -103,7 +103,7 @@ static DetectThresholdData *DetectDetectionFilterParse (const char *rawstr)
char *copy_str = NULL, *df_opt = NULL; char *copy_str = NULL, *df_opt = NULL;
int seconds_found = 0, count_found = 0, track_found = 0; int seconds_found = 0, count_found = 0, track_found = 0;
int seconds_pos = 0, count_pos = 0; int seconds_pos = 0, count_pos = 0;
uint16_t pos = 0; size_t pos = 0;
int i = 0; int i = 0;
char *saveptr = NULL; char *saveptr = NULL;

@ -599,9 +599,8 @@ static uint32_t PrefilterStoreHashFunc(HashListTable *ht, void *data, uint16_t d
PrefilterStore *ctx = data; PrefilterStore *ctx = data;
uint32_t hash = strlen(ctx->name); uint32_t hash = strlen(ctx->name);
uint16_t u;
for (u = 0; u < strlen(ctx->name); u++) { for (size_t u = 0; u < strlen(ctx->name); u++) {
hash += ctx->name[u]; hash += ctx->name[u];
} }

@ -65,7 +65,7 @@ static int DetectMsgSetup (DetectEngineCtx *de_ctx, Signature *s, const char *ms
char converted = 0; char converted = 0;
{ {
uint16_t i, x; size_t i, x;
uint8_t escape = 0; uint8_t escape = 0;
/* it doesn't matter if we need to escape or not we remove the extra "\" to mimic snort */ /* it doesn't matter if we need to escape or not we remove the extra "\" to mimic snort */

@ -118,7 +118,7 @@ static DetectThresholdData *DetectThresholdParse(const char *rawstr)
int second_found = 0, count_found = 0; int second_found = 0, count_found = 0;
int type_found = 0, track_found = 0; int type_found = 0, track_found = 0;
int second_pos = 0, count_pos = 0; int second_pos = 0, count_pos = 0;
uint16_t pos = 0; size_t pos = 0;
int i = 0; int i = 0;
copy_str = SCStrdup(rawstr); copy_str = SCStrdup(rawstr);

Loading…
Cancel
Save