http/xff: harden code against http in detection-only

pull/15752/head
Victor Julien 2 months ago
parent c01aa71b56
commit c1392d99a3

@ -182,17 +182,14 @@ int HttpXFFGetIPFromTx(
*/ */
int HttpXFFGetIP(const Flow *f, HttpXFFCfg *xff_cfg, char *dstbuf, int dstbuflen) int HttpXFFGetIP(const Flow *f, HttpXFFCfg *xff_cfg, char *dstbuf, int dstbuflen)
{ {
HtpState *htp_state = NULL; HtpState *htp_state = (HtpState *)FlowGetAppState(f);
uint64_t tx_id = AppLayerParserGetMinId(f->alparser);
uint64_t total_txs = 0;
htp_state = (HtpState *)FlowGetAppState(f);
if (htp_state == NULL) { if (htp_state == NULL) {
SCLogDebug("no http state, XFF IP cannot be retrieved"); SCLogDebug("no http state, XFF IP cannot be retrieved");
goto end; goto end;
} }
total_txs = AppLayerParserGetTxCnt(f, htp_state); uint64_t tx_id = AppLayerParserGetMinId(f->alparser);
const uint64_t total_txs = AppLayerParserGetTxCnt(f, htp_state);
AppLayerGetTxIteratorFunc IterFunc = AppLayerGetTxIterator(f->proto, f->alproto); AppLayerGetTxIteratorFunc IterFunc = AppLayerGetTxIterator(f->proto, f->alproto);
AppLayerGetTxIterState state; AppLayerGetTxIterState state;
memset(&state, 0, sizeof(state)); memset(&state, 0, sizeof(state));

Loading…
Cancel
Save