app-layer: use macro for progress ceiling

pull/15846/head
Victor Julien 4 months ago
parent 2e1003a026
commit 17a3e0d44f

@ -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;
}
}

@ -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);

@ -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);

@ -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);

@ -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;

@ -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

Loading…
Cancel
Save