Skip to content

Commit

Permalink
tx: configurable number of maximum transactions
Browse files Browse the repository at this point in the history
Ticket: #5921
  • Loading branch information
catenacyber authored and victorjulien committed Jan 26, 2024
1 parent 2fa8691 commit 6e35e93
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions htp/htp_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,11 @@ void htp_config_set_lzma_layers(htp_cfg_t *cfg, int limit) {
cfg->response_lzma_layer_limit = limit;
}

void htp_config_set_max_tx(htp_cfg_t *cfg, uint32_t limit) {
if (cfg == NULL) return;
cfg->max_tx = limit;
}

void htp_config_set_compression_bomb_limit(htp_cfg_t *cfg, size_t bomblimit) {
if (cfg == NULL) return;
if (bomblimit > INT32_MAX) {
Expand Down
8 changes: 8 additions & 0 deletions htp/htp_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,14 @@ void htp_config_set_compression_bomb_limit(htp_cfg_t *cfg, size_t bomblimit);
*/
void htp_config_set_compression_time_limit(htp_cfg_t *cfg, size_t useclimit);

/**
* Configures the maximum number of tx LibHTP will have per connection.
*
* @param[in] cfg
* @param[in] limit
*/
void htp_config_set_max_tx(htp_cfg_t *cfg, uint32_t limit);

/**
* Configures the desired log level.
*
Expand Down
3 changes: 3 additions & 0 deletions htp/htp_config_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ struct htp_cfg_t {

/** Whether to decompress compressed request bodies. */
int request_decompression_enabled;

/** Maximum number of transactions. */
uint32_t max_tx;
};

#ifdef __cplusplus
Expand Down
4 changes: 4 additions & 0 deletions htp/htp_connection_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ htp_tx_t *htp_connp_tx_create(htp_connp_t *connp) {
if (htp_list_size(connp->conn->transactions) > connp->out_next_tx_index) {
connp->conn->flags |= HTP_CONN_PIPELINED;
}
if (connp->cfg->max_tx > 0 &&
htp_list_size(connp->conn->transactions) > connp->cfg->max_tx) {
return NULL;
}

htp_tx_t *tx = htp_tx_create(connp);
if (tx == NULL) return NULL;
Expand Down

0 comments on commit 6e35e93

Please sign in to comment.