http: improve body pruning

In case the body wasn't inspected the body_inspected variable wouldn't
get updated leading to the body not getting pruned at all.

This patch adds support for this case.
pull/1790/head
Victor Julien 10 years ago
parent 64017cd29b
commit efdd9e08f2

@ -222,7 +222,16 @@ void HtpBodyPrune(HtpState *state, HtpBody *body, int direction)
window = state->cfg->request_inspect_window;
}
if (body->body_inspected < ((min_size > window) ? min_size : window)) {
uint64_t max_window = ((min_size > window) ? min_size : window);
uint64_t in_flight = body->content_len_so_far - body->body_inspected;
/* Special case. If body_inspected is not being updated, we make sure that
* we prune the body. We allow for some extra size/room as we may be called
* multiple times on uninspected body chunk additions if a large block of
* data was ack'd at once. Want to avoid pruning before inspection. */
if (in_flight > (max_window * 3)) {
body->body_inspected = body->content_len_so_far - max_window;
} else if (body->body_inspected < max_window) {
SCReturn;
}

@ -1812,6 +1812,9 @@ int HTPCallbackRequestBodyData(htp_tx_data_t *d)
}
}
/* see if we can get rid of htp body chunks */
HtpBodyPrune(hstate, &tx_ud->request_body, STREAM_TOSERVER);
SCLogDebug("tx_ud->request_body.content_len_so_far %"PRIu64, tx_ud->request_body.content_len_so_far);
SCLogDebug("hstate->cfg->request_body_limit %u", hstate->cfg->request_body_limit);
@ -1863,9 +1866,6 @@ int HTPCallbackRequestBodyData(htp_tx_data_t *d)
}
end:
/* see if we can get rid of htp body chunks */
HtpBodyPrune(hstate, &tx_ud->request_body, STREAM_TOSERVER);
/* set the new chunk flag */
hstate->flags |= HTP_FLAG_NEW_BODY_SET;
@ -1911,6 +1911,9 @@ int HTPCallbackResponseBodyData(htp_tx_data_t *d)
tx_ud->operation = HTP_BODY_RESPONSE;
}
/* see if we can get rid of htp body chunks */
HtpBodyPrune(hstate, &tx_ud->response_body, STREAM_TOCLIENT);
SCLogDebug("tx_ud->response_body.content_len_so_far %"PRIu64, tx_ud->response_body.content_len_so_far);
SCLogDebug("hstate->cfg->response_body_limit %u", hstate->cfg->response_body_limit);
@ -1932,9 +1935,6 @@ int HTPCallbackResponseBodyData(htp_tx_data_t *d)
HtpResponseBodyHandle(hstate, tx_ud, d->tx, (uint8_t *)d->data, (uint32_t)d->len);
}
/* see if we can get rid of htp body chunks */
HtpBodyPrune(hstate, &tx_ud->response_body, STREAM_TOCLIENT);
/* set the new chunk flag */
hstate->flags |= HTP_FLAG_NEW_BODY_SET;

Loading…
Cancel
Save