#include "util-streaming-buffer.h"
#include "util-print.h"
-static StreamingBufferConfig default_cfg = { 3072, 1, STREAMING_BUFFER_REGION_GAP_DEFAULT,
- HTPCalloc, HTPRealloc, HTPFree };
+extern StreamingBufferConfig htp_sbcfg;
/**
* \brief Append a chunk of body to the HtpBody struct
}
if (body->sb == NULL) {
- const StreamingBufferConfig *cfg = hcfg ? &hcfg->sbcfg : &default_cfg;
- body->sb = StreamingBufferInit(cfg);
+ body->sb = StreamingBufferInit(&htp_sbcfg);
if (body->sb == NULL)
SCReturnInt(-1);
}
SCReturnInt(-1);
}
- if (StreamingBufferAppend(body->sb, &hcfg->sbcfg, &bd->sbseg, data, len) != 0) {
+ if (StreamingBufferAppend(body->sb, &htp_sbcfg, &bd->sbseg, data, len) != 0) {
HTPFree(bd, sizeof(HtpBodyChunk));
SCReturnInt(-1);
}
}
body->first = body->last = NULL;
- StreamingBufferFree(body->sb, &hcfg->sbcfg);
+ StreamingBufferFree(body->sb, &htp_sbcfg);
}
/**
if (left_edge) {
SCLogDebug("sliding body to offset %"PRIu64, left_edge);
- StreamingBufferSlideToOffset(body->sb, &cfg->sbcfg, left_edge);
+ StreamingBufferSlideToOffset(body->sb, &htp_sbcfg, left_edge);
}
SCLogDebug("pruning chunks of body %p", body);
#include "app-layer-htp-range.h"
#include "util-validate.h"
+extern StreamingBufferConfig htp_sbcfg;
+
/**
* \brief Open the file with "filename" and pass the first chunk
* of data if any.
int retval = 0;
uint16_t flags = 0;
FileContainer *files = NULL;
- const StreamingBufferConfig *sbcfg = NULL;
SCLogDebug("data %p data_len %"PRIu32, data, data_len);
if (direction & STREAM_TOCLIENT) {
files = &tx->files_tc;
flags = FileFlowFlagsToFlags(tx->tx_data.file_flags, STREAM_TOCLIENT);
- sbcfg = &s->cfg->response.sbcfg;
// we shall not open a new file if there is a current one
DEBUG_VALIDATE_BUG_ON(tx->file_range != NULL);
} else {
files = &tx->files_ts;
flags = FileFlowFlagsToFlags(tx->tx_data.file_flags, STREAM_TOSERVER);
- sbcfg = &s->cfg->request.sbcfg;
}
- if (FileOpenFileWithId(files, sbcfg, s->file_track_id++,
- filename, filename_len,
- data, data_len, flags) != 0)
- {
+ if (FileOpenFileWithId(files, &htp_sbcfg, s->file_track_id++, filename, filename_len, data,
+ data_len, flags) != 0) {
retval = -1;
}
FileContainer *files = &txud->files_tc;
// we open a file for this specific range
- if (FileOpenFileWithId(files, &s->cfg->response.sbcfg, s->file_track_id++, filename,
- filename_len, data, data_len, flags) != 0) {
+ if (FileOpenFileWithId(files, &htp_sbcfg, s->file_track_id++, filename, filename_len, data,
+ data_len, flags) != 0) {
SCReturnInt(-1);
}
txud->tx_data.files_opened++;
SCReturnInt(0);
}
DEBUG_VALIDATE_BUG_ON(htud->file_range);
- htud->file_range = HttpRangeContainerOpenFile(keyurl, keylen, s->f, &crparsed,
- &s->cfg->response.sbcfg, filename, filename_len, flags, data, data_len);
+ htud->file_range = HttpRangeContainerOpenFile(keyurl, keylen, s->f, &crparsed, &htp_sbcfg,
+ filename, filename_len, flags, data, data_len);
SCFree(keyurl);
if (htud->file_range == NULL) {
SCReturnInt(-1);
int retval = 0;
int result = 0;
FileContainer *files = NULL;
- const StreamingBufferConfig *sbcfg = NULL;
if (direction & STREAM_TOCLIENT) {
files = &tx->files_tc;
- sbcfg = &s->cfg->response.sbcfg;
} else {
files = &tx->files_ts;
- sbcfg = &s->cfg->request.sbcfg;
}
SCLogDebug("files %p data %p data_len %" PRIu32, files, data, data_len);
}
if (tx->file_range != NULL) {
- if (HttpRangeAppendData(sbcfg, tx->file_range, data, data_len) < 0) {
+ if (HttpRangeAppendData(&htp_sbcfg, tx->file_range, data, data_len) < 0) {
SCLogDebug("Failed to append data");
}
}
- result = FileAppendData(files, sbcfg, data, data_len);
+ result = FileAppendData(files, &htp_sbcfg, data, data_len);
if (result == -1) {
SCLogDebug("appending data failed");
retval = -1;
int retval = 0;
int result = 0;
FileContainer *files = NULL;
- const StreamingBufferConfig *sbcfg = NULL;
if (direction & STREAM_TOCLIENT) {
files = &tx->files_tc;
- sbcfg = &s->cfg->response.sbcfg;
} else {
files = &tx->files_ts;
- sbcfg = &s->cfg->request.sbcfg;
}
SCLogDebug("files %p data %p data_len %" PRIu32, files, data, data_len);
goto end;
}
- result = FileCloseFile(files, sbcfg, data, data_len, flags);
+ result = FileCloseFile(files, &htp_sbcfg, data, data_len, flags);
if (result == -1) {
retval = -1;
} else if (result == -2) {
SCLogDebug("result %u", result);
if (tx->file_range != NULL) {
- bool added = HTPFileCloseHandleRange(sbcfg, files, flags, tx->file_range, data, data_len);
+ bool added =
+ HTPFileCloseHandleRange(&htp_sbcfg, files, flags, tx->file_range, data, data_len);
if (added) {
tx->tx_data.files_opened++;
}
/** List of HTP configurations. */
static HTPCfgRec cfglist;
+StreamingBufferConfig htp_sbcfg = STREAMING_BUFFER_CONFIG_INITIALIZER;
+
/** Limit to the number of libhtp messages that can be handled */
#define HTP_MAX_MESSAGES 512
DetectEngineStateFree(htud->tx_data.de_state);
}
if (htud->file_range) {
- HTPFileCloseHandleRange(
- &state->cfg->response.sbcfg, &htud->files_tc, 0, htud->file_range, NULL, 0);
+ HTPFileCloseHandleRange(&htp_sbcfg, &htud->files_tc, 0, htud->file_range, NULL, 0);
HttpRangeFreeBlock(htud->file_range);
}
- FileContainerRecycle(&htud->files_ts, &state->cfg->request.sbcfg);
- FileContainerRecycle(&htud->files_tc, &state->cfg->response.sbcfg);
+ FileContainerRecycle(&htud->files_ts, &htp_sbcfg);
+ FileContainerRecycle(&htud->files_tc, &htp_sbcfg);
HTPFree(htud, sizeof(HtpTxUserData));
}
}
}
htp_config_register_request_line(cfg_prec->cfg, HTPCallbackRequestLine);
-
- cfg_prec->request.sbcfg.buf_size =
- cfg_prec->request.inspect_window ? cfg_prec->request.inspect_window : 256;
- cfg_prec->request.sbcfg.Calloc = HTPCalloc;
- cfg_prec->request.sbcfg.Realloc = HTPRealloc;
- cfg_prec->request.sbcfg.Free = HTPFree;
-
- cfg_prec->response.sbcfg.buf_size =
- cfg_prec->response.inspect_window ? cfg_prec->response.inspect_window : 256;
- cfg_prec->response.sbcfg.Calloc = HTPCalloc;
- cfg_prec->response.sbcfg.Realloc = HTPRealloc;
- cfg_prec->response.sbcfg.Free = HTPFree;
return;
}
cfglist.next = NULL;
+ htp_sbcfg.Calloc = HTPCalloc;
+ htp_sbcfg.Realloc = HTPRealloc;
+ htp_sbcfg.Free = HTPFree;
+
cfgtree = SCRadixCreateRadixTree(NULL, NULL);
if (NULL == cfgtree)
exit(EXIT_FAILURE);
*/
static AppLayerGetFileState HTPGetTxFiles(void *state, void *txv, uint8_t direction)
{
- AppLayerGetFileState files = { .fc = NULL, .cfg = NULL };
- HtpState *s = state;
+ AppLayerGetFileState files = { .fc = NULL, .cfg = &htp_sbcfg };
htp_tx_t *tx = (htp_tx_t *)txv;
HtpTxUserData *tx_ud = htp_tx_get_user_data(tx);
if (tx_ud) {
if (direction & STREAM_TOCLIENT) {
files.fc = &tx_ud->files_tc;
- files.cfg = &s->cfg->response.sbcfg;
} else {
files.fc = &tx_ud->files_ts;
- files.cfg = &s->cfg->request.sbcfg;
}
}
return files;