From: Victor Julien Date: Thu, 19 Jun 2014 08:36:36 +0000 (+0200) Subject: htp: make htp state handling function more robust X-Git-Tag: suricata-2.0.2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=896b61452c99b01cbcd7215d3732804431c93796;p=thirdparty%2Fsuricata.git htp: make htp state handling function more robust Also, fix wrong cast that worked only by luck. --- diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index 125ce3e1e1..c91cfbd0eb 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -2571,12 +2571,22 @@ static int HTPStateGetAlstateProgress(void *tx, uint8_t direction) static uint64_t HTPStateGetTxCnt(void *alstate) { - return (uint64_t)htp_list_size(((htp_tx_t *)alstate)->conn->transactions); + HtpState *http_state = (HtpState *)alstate; + + if (http_state != NULL && http_state->conn != NULL) + return (uint64_t)htp_list_size(http_state->conn->transactions); + else + return 0ULL; } static void *HTPStateGetTx(void *alstate, uint64_t tx_id) { - return htp_list_get(((htp_tx_t *)alstate)->conn->transactions, tx_id); + HtpState *http_state = (HtpState *)alstate; + + if (http_state != NULL && http_state->conn != NULL) + return htp_list_get(http_state->conn->transactions, tx_id); + else + return NULL; } static int HTPStateGetAlstateProgressCompletionStatus(uint8_t direction)