From 148883cedfb0d902462aafc6e958b5172e3b76c5 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sat, 6 Feb 2010 11:22:47 +0100 Subject: [PATCH] Work around for unsupported CONNECT support handling. --- src/app-layer-htp.c | 49 +++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index 833160ceb9..df6bceda42 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -158,15 +158,20 @@ static int HTPHandleRequestData(Flow *f, void *htp_state, } r = htp_connp_req_data(hstate->connp, 0, input, input_len); - if(r == STREAM_STATE_ERROR) + if (r == STREAM_STATE_ERROR || r == STREAM_STATE_DATA_OTHER) { - if (hstate->connp->last_error != NULL) { - SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP client request: " - "[%"PRId32"] [%s] [%"PRId32"] %s", hstate->connp->last_error->level, - hstate->connp->last_error->file, hstate->connp->last_error->line, - hstate->connp->last_error->msg); + if (r == STREAM_STATE_DATA_OTHER) { + SCLogDebug("CONNECT not supported yet"); } else { - SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP client request"); + + if (hstate->connp->last_error != NULL) { + SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP client request: " + "[%"PRId32"] [%s] [%"PRId32"] %s", hstate->connp->last_error->level, + hstate->connp->last_error->file, hstate->connp->last_error->line, + hstate->connp->last_error->msg); + } else { + SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP client request"); + } } hstate->flags |= HTP_FLAG_STATE_ERROR; hstate->flags &= ~HTP_FLAG_STATE_DATA; @@ -216,18 +221,23 @@ static int HTPHandleResponseData(Flow *f, void *htp_state, HtpState *hstate = (HtpState *)htp_state; r = htp_connp_res_data(hstate->connp, 0, input, input_len); - if (r == STREAM_STATE_ERROR) + if (r == STREAM_STATE_ERROR || r == STREAM_STATE_DATA_OTHER) { - if (hstate->connp->last_error != NULL) { - SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP server response: " - "[%"PRId32"] [%s] [%"PRId32"] %s", hstate->connp->last_error->level, - hstate->connp->last_error->file, hstate->connp->last_error->line, - hstate->connp->last_error->msg); - } else { - SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP server response"); - } - hstate->flags = HTP_FLAG_STATE_ERROR; - ret = -1; + if (r == STREAM_STATE_DATA_OTHER) { + SCLogDebug("CONNECT not supported yet"); + } else { + + if (hstate->connp->last_error != NULL) { + SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP server response: " + "[%"PRId32"] [%s] [%"PRId32"] %s", hstate->connp->last_error->level, + hstate->connp->last_error->file, hstate->connp->last_error->line, + hstate->connp->last_error->msg); + } else { + SCLogError(SC_ALPARSER_ERR, "Error in parsing HTTP server response"); + } + } + hstate->flags = HTP_FLAG_STATE_ERROR; + ret = -1; } else if (r == STREAM_STATE_DATA) { hstate->flags |= HTP_FLAG_STATE_DATA; @@ -291,9 +301,8 @@ static int HTPCallbackResponse(htp_connp_t *connp) { SCEnter(); HtpState *hstate = (HtpState *)connp->user_data; htp_tx_t *tx = NULL; - uint8_t i = 0; - for (i=0; i < list_size(hstate->recent_in_tx) - 1; i++) { + while (list_size(hstate->recent_in_tx) > 0) { tx = list_pop(hstate->recent_in_tx); if (tx != NULL) htp_tx_destroy(tx);