Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http1 removetx 5921 v12 #423

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions htp/htp_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ void htp_conn_destroy(htp_conn_t *conn) {
for (size_t i = 0, n = htp_list_size(conn->transactions); i < n; i++) {
htp_tx_t *tx = htp_list_get(conn->transactions, i);
if (tx != NULL) {
// nullify conn so as not to call htp_conn_remove_tx
// since we remove all txs
tx->conn = NULL;
htp_tx_destroy_incomplete(tx);
}
}
Expand Down Expand Up @@ -148,10 +151,11 @@ htp_status_t htp_conn_open(htp_conn_t *conn, const char *client_addr, int client
htp_status_t htp_conn_remove_tx(htp_conn_t *conn, const htp_tx_t *tx) {
if ((tx == NULL) || (conn == NULL)) return HTP_ERROR;
if (conn->transactions == NULL) return HTP_ERROR;
for (size_t i = 0, n = htp_list_size(conn->transactions); i < n; i++) {
htp_tx_t *tx2 = htp_list_get(conn->transactions, i);
if (tx2 == tx) {
return htp_list_replace(conn->transactions, i, NULL);
size_t n = htp_list_size(conn->transactions);
if (n > 0) {
htp_tx_t *tx2 = htp_list_get(conn->transactions, n - 1);
if (tx2 != NULL) {
return htp_list_replace(conn->transactions, n - 1 + tx->index - tx2->index, NULL);
}
}
return HTP_DECLINED;
Expand Down
8 changes: 7 additions & 1 deletion htp/htp_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ htp_tx_t *htp_tx_create(htp_connp_t *connp) {

tx->connp = connp;
tx->conn = connp->conn;
tx->index = htp_list_size(tx->conn->transactions);
tx->index = 0;
if (htp_list_size(tx->conn->transactions) > 0) {
htp_tx_t *txl = htp_list_get(tx->conn->transactions, htp_list_size(tx->conn->transactions) - 1);
if (txl != NULL) {
tx->index = txl->index + 1;
}
}
tx->cfg = connp->cfg;
tx->is_config_shared = HTP_CONFIG_SHARED;

Expand Down
Loading