diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index a807a9b640..c746588249 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -1288,7 +1288,7 @@ int8_t AppLayerParserGetSubStateProgressId( return -1; } SCLogDebug("state:%s v:%u", state, v); - BUG_ON(v > 48); + BUG_ON(v >= APP_LAYER_MAX_PROGRESS); return (int8_t)v; } } diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index a95f270d3a..ebddac421c 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -71,6 +71,9 @@ typedef struct AppLayerGetFileState AppLayerGetFileState; int AppLayerParserProtoIsRegistered(uint8_t ipproto, AppProto alproto); +/** progress values need to stay under this. */ +#define APP_LAYER_MAX_PROGRESS 48 + /***** transaction handling *****/ int AppLayerParserSetup(void); diff --git a/src/detect-engine-mpm.c b/src/detect-engine-mpm.c index 1aae1b56a0..7803d00537 100644 --- a/src/detect-engine-mpm.c +++ b/src/detect-engine-mpm.c @@ -104,7 +104,7 @@ static void RegisterInternal(const char *name, int direction, int priority, DEBUG_VALIDATE_BUG_ON(AppLayerParserSupportsSubStates(alproto) && sub_state == 0); DEBUG_VALIDATE_BUG_ON(!AppLayerParserSupportsSubStates(alproto) && sub_state != 0); - BUG_ON(tx_min_progress >= 48); + BUG_ON(tx_min_progress >= APP_LAYER_MAX_PROGRESS); // must register GetData with PrefilterGenericMpmRegister BUG_ON(PrefilterRegister == PrefilterGenericMpmRegister && GetData == NULL); diff --git a/src/detect-engine.c b/src/detect-engine.c index 282814b3f9..ed1f36651d 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -207,7 +207,7 @@ static void AppLayerInspectEngineRegisterInternal(const char *name, AppProto alp DEBUG_VALIDATE_BUG_ON(AppLayerParserSupportsSubStates(alproto) && sub_state == 0); DEBUG_VALIDATE_BUG_ON(!AppLayerParserSupportsSubStates(alproto) && sub_state != 0); } - BUG_ON(progress >= 48); + BUG_ON(progress >= APP_LAYER_MAX_PROGRESS); DetectBufferTypeRegister(name); const int sm_list = DetectBufferTypeGetByName(name); diff --git a/src/detect-parse.c b/src/detect-parse.c index 2c055eb3d9..80c93b51e2 100644 --- a/src/detect-parse.c +++ b/src/detect-parse.c @@ -1479,7 +1479,7 @@ static int SigParseProtoHookApp( const int progress_ts = AppLayerParserGetStateIdByName( IPPROTO_TCP /* TODO */, s->alproto, h, STREAM_TOSERVER); if (progress_ts >= 0) { - if (progress_ts >= 48) { + if (progress_ts >= APP_LAYER_MAX_PROGRESS) { return -1; } s->flags |= SIG_FLAG_TOSERVER; @@ -1487,7 +1487,7 @@ static int SigParseProtoHookApp( } else { const int progress_tc = AppLayerParserGetStateIdByName( IPPROTO_TCP /* TODO */, s->alproto, h, STREAM_TOCLIENT); - if (progress_tc < 0 || progress_tc >= 48) { + if (progress_tc < 0 || progress_tc >= APP_LAYER_MAX_PROGRESS) { return -1; } s->flags |= SIG_FLAG_TOCLIENT; diff --git a/src/detect.c b/src/detect.c index 75258837c3..96ce6c1ef8 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1564,12 +1564,12 @@ static int DetectRunTxInspectRule(ThreadVars *tv, DetectEngineCtx *de_ctx, static DetectTransaction GetDetectTx(const uint8_t ipproto, const AppProto alproto, const uint64_t tx_id, void *tx_ptr, const int tx_end_state, const uint8_t flow_flags) { - DEBUG_VALIDATE_BUG_ON(tx_end_state >= 48); + DEBUG_VALIDATE_BUG_ON(tx_end_state >= APP_LAYER_MAX_PROGRESS); AppLayerTxData *txd = AppLayerParserGetTxData(ipproto, alproto, tx_ptr); const uint8_t tx_progress = (uint8_t)AppLayerParserGetStateProgress(ipproto, alproto, tx_ptr, flow_flags); - DEBUG_VALIDATE_BUG_ON(tx_progress >= 48); + DEBUG_VALIDATE_BUG_ON(tx_progress >= APP_LAYER_MAX_PROGRESS); const uint8_t e_tx_end_state = txd->tx_type == 0 ? (uint8_t)tx_end_state : (flow_flags & STREAM_TOSERVER) ? txd->tx_type_eop_ts