From: Victor Julien Date: Wed, 17 Oct 2012 16:24:56 +0000 (+0200) Subject: http: now that htp_state has a cfg reference, use it for body limits X-Git-Tag: suricata-1.4beta3~71 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5cd46433d331819d2c4676e0fd26182bf18ebf89;p=thirdparty%2Fsuricata.git http: now that htp_state has a cfg reference, use it for body limits --- diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index 674dd7d9ee..d1fadcd556 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -594,15 +594,9 @@ static int HTPHandleRequestData(Flow *f, void *htp_state, if (htp_cfg_rec != NULL) { htp = htp_cfg_rec->cfg; SCLogDebug("LIBHTP using config: %p", htp); - - hstate->request_body_limit = htp_cfg_rec->request_body_limit; - hstate->response_body_limit = htp_cfg_rec->response_body_limit; } } else { SCLogDebug("Using default HTP config: %p", htp); - - hstate->request_body_limit = cfglist.request_body_limit; - hstate->response_body_limit = cfglist.response_body_limit; } if (NULL == htp) { @@ -1806,17 +1800,17 @@ int HTPCallbackRequestBodyData(htp_tx_data_t *d) } SCLogDebug("htud->request_body.content_len_so_far %"PRIu64, htud->request_body.content_len_so_far); - SCLogDebug("hstate->request_body_limit %u", hstate->request_body_limit); + SCLogDebug("hstate->cfg->request_body_limit %u", hstate->cfg->request_body_limit); /* within limits, add the body chunk to the state. */ - if (hstate->request_body_limit == 0 || htud->request_body.content_len_so_far < hstate->request_body_limit) + if (hstate->cfg->request_body_limit == 0 || htud->request_body.content_len_so_far < hstate->cfg->request_body_limit) { uint32_t len = (uint32_t)d->len; - if (hstate->request_body_limit > 0 && - (htud->request_body.content_len_so_far + len) > hstate->request_body_limit) + if (hstate->cfg->request_body_limit > 0 && + (htud->request_body.content_len_so_far + len) > hstate->cfg->request_body_limit) { - len = hstate->request_body_limit - htud->request_body.content_len_so_far; + len = hstate->cfg->request_body_limit - htud->request_body.content_len_so_far; BUG_ON(len > (uint32_t)d->len); } SCLogDebug("len %u", len); @@ -1824,8 +1818,8 @@ int HTPCallbackRequestBodyData(htp_tx_data_t *d) int r = HtpBodyAppendChunk(htud, &htud->request_body, (uint8_t *)d->data, len); if (r < 0) { htud->tsflags |= HTP_REQ_BODY_COMPLETE; - } else if (hstate->request_body_limit > 0 && - htud->request_body.content_len_so_far >= hstate->request_body_limit) + } else if (hstate->cfg->request_body_limit > 0 && + htud->request_body.content_len_so_far >= hstate->cfg->request_body_limit) { htud->tsflags |= HTP_REQ_BODY_COMPLETE; } else if (htud->request_body.content_len_so_far == htud->request_body.content_len) { @@ -1912,17 +1906,17 @@ int HTPCallbackResponseBodyData(htp_tx_data_t *d) } SCLogDebug("htud->response_body.content_len_so_far %"PRIu64, htud->response_body.content_len_so_far); - SCLogDebug("hstate->response_body_limit %u", hstate->response_body_limit); + SCLogDebug("hstate->cfg->response_body_limit %u", hstate->cfg->response_body_limit); /* within limits, add the body chunk to the state. */ - if (hstate->response_body_limit == 0 || htud->response_body.content_len_so_far < hstate->response_body_limit) + if (hstate->cfg->response_body_limit == 0 || htud->response_body.content_len_so_far < hstate->cfg->response_body_limit) { uint32_t len = (uint32_t)d->len; - if (hstate->response_body_limit > 0 && - (htud->response_body.content_len_so_far + len) > hstate->response_body_limit) + if (hstate->cfg->response_body_limit > 0 && + (htud->response_body.content_len_so_far + len) > hstate->cfg->response_body_limit) { - len = hstate->response_body_limit - htud->response_body.content_len_so_far; + len = hstate->cfg->response_body_limit - htud->response_body.content_len_so_far; BUG_ON(len > (uint32_t)d->len); } SCLogDebug("len %u", len); @@ -1930,8 +1924,8 @@ int HTPCallbackResponseBodyData(htp_tx_data_t *d) int r = HtpBodyAppendChunk(htud, &htud->response_body, (uint8_t *)d->data, len); if (r < 0) { htud->tcflags |= HTP_RES_BODY_COMPLETE; - } else if (hstate->response_body_limit > 0 && - htud->response_body.content_len_so_far >= hstate->response_body_limit) + } else if (hstate->cfg->response_body_limit > 0 && + htud->response_body.content_len_so_far >= hstate->cfg->response_body_limit) { htud->tcflags |= HTP_RES_BODY_COMPLETE; } else if (htud->response_body.content_len_so_far == htud->response_body.content_len) { diff --git a/src/app-layer-htp.h b/src/app-layer-htp.h index 69ae35630e..90471e4b73 100644 --- a/src/app-layer-htp.h +++ b/src/app-layer-htp.h @@ -217,8 +217,6 @@ typedef struct HtpState_ { uint16_t transaction_cnt; uint16_t transaction_done; uint16_t store_tx_id; - uint32_t request_body_limit; - uint32_t response_body_limit; FileContainer *files_ts; FileContainer *files_tc; struct HTPCfgRec_ *cfg;