http: improve body pruning

Take inspect window into account.
pull/1528/head
Victor Julien 11 years ago
parent 0bbc818b2d
commit 9fa2f85cc7

@ -199,7 +199,7 @@ void HtpBodyFree(HtpBody *body)
*
* \retval none
*/
void HtpBodyPrune(HtpBody *body)
void HtpBodyPrune(HtpState *state, HtpBody *body)
{
SCEnter();
@ -211,6 +211,10 @@ void HtpBodyPrune(HtpBody *body)
SCReturn;
}
if (body->body_inspected < state->cfg->response_inspect_min_size) {
SCReturn;
}
SCLogDebug("Pruning chunks of Body %p; data %p, len %"PRIu32, body,
body->last->data, (uint32_t)body->last->len);
@ -222,7 +226,12 @@ void HtpBodyPrune(HtpBody *body)
"body->body_parsed %"PRIu64, cur->stream_offset, cur->len,
cur->stream_offset + cur->len, body->body_parsed);
if (cur->stream_offset >= body->body_inspected) {
uint64_t left_edge = 0;
if (state->cfg->response_inspect_window < body->body_inspected) {
left_edge = body->body_inspected - state->cfg->response_inspect_window;
}
if (cur->stream_offset >= left_edge) {
break;
}

@ -31,6 +31,6 @@
int HtpBodyAppendChunk(HtpTxUserData *, HtpBody *, uint8_t *, uint32_t);
void HtpBodyPrint(HtpBody *);
void HtpBodyFree(HtpBody *);
void HtpBodyPrune(HtpBody *);
void HtpBodyPrune(HtpState *, HtpBody *);
#endif /* __APP_LAYER_HTP_BODY_H__ */

@ -1848,7 +1848,7 @@ int HTPCallbackRequestBodyData(htp_tx_data_t *d)
end:
/* see if we can get rid of htp body chunks */
HtpBodyPrune(&tx_ud->request_body);
HtpBodyPrune(hstate, &tx_ud->request_body);
/* set the new chunk flag */
hstate->flags |= HTP_FLAG_NEW_BODY_SET;
@ -1917,7 +1917,7 @@ int HTPCallbackResponseBodyData(htp_tx_data_t *d)
}
/* see if we can get rid of htp body chunks */
HtpBodyPrune(&tx_ud->response_body);
HtpBodyPrune(hstate, &tx_ud->response_body);
/* set the new chunk flag */
hstate->flags |= HTP_FLAG_NEW_BODY_SET;

Loading…
Cancel
Save