From: Victor Julien Date: Wed, 26 Feb 2014 06:01:09 +0000 (+0100) Subject: htp: fix pointer check logic X-Git-Tag: suricata-2.0rc2~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b734b8d8a45728cf88f115ca904f0c4683305ff;p=thirdparty%2Fsuricata.git htp: fix pointer check logic Don't check pointer after it has already been used. Coverity 1047545 --- diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index 7e132aa8fa..194b57971e 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -1957,6 +1957,10 @@ void HTPFreeConfig(void) static int HTPCallbackRequest(htp_tx_t *tx) { SCEnter(); + if (tx == NULL) { + SCReturnInt(HTP_ERROR); + } + HtpState *hstate = htp_connp_get_user_data(tx->connp); if (hstate == NULL) { SCReturnInt(HTP_ERROR); @@ -1967,16 +1971,14 @@ static int HTPCallbackRequest(htp_tx_t *tx) { SCLogDebug("HTTP request completed"); - if (tx != NULL) { - HTPErrorCheckTxRequestFlags(hstate, tx); + HTPErrorCheckTxRequestFlags(hstate, tx); - HtpTxUserData *htud = (HtpTxUserData *)htp_tx_get_user_data(tx); - if (htud != NULL) { - if (htud->tsflags & HTP_FILENAME_SET) { - SCLogDebug("closing file that was being stored"); - (void)HTPFileClose(hstate, NULL, 0, 0, STREAM_TOSERVER); - htud->tsflags &= ~HTP_FILENAME_SET; - } + HtpTxUserData *htud = (HtpTxUserData *)htp_tx_get_user_data(tx); + if (htud != NULL) { + if (htud->tsflags & HTP_FILENAME_SET) { + SCLogDebug("closing file that was being stored"); + (void)HTPFileClose(hstate, NULL, 0, 0, STREAM_TOSERVER); + htud->tsflags &= ~HTP_FILENAME_SET; } }