From: Jason Ish Date: Mon, 2 May 2022 18:19:51 +0000 (-0600) Subject: dcerpc: convert transaction list to vecdeque X-Git-Tag: suricata-6.0.13~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee77e2e60b8d1eeab4301c88e74ac101bbab0c0e;p=thirdparty%2Fsuricata.git dcerpc: convert transaction list to vecdeque Allows for more efficient removal from front of the list. Ticket: #5271 (cherry picked from commit dfe76bb905409bf91345e972f2ab157bda51f003) --- diff --git a/rust/src/dcerpc/dcerpc.rs b/rust/src/dcerpc/dcerpc.rs index b9ee26e817..b874954ee2 100644 --- a/rust/src/dcerpc/dcerpc.rs +++ b/rust/src/dcerpc/dcerpc.rs @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Open Information Security Foundation +/* Copyright (C) 2020-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -23,6 +23,7 @@ use nom::error::ErrorKind; use nom::number::Endianness; use nom; use std::cmp; +use std::collections::VecDeque; // Constant DCERPC UDP Header length pub const DCERPC_HDR_LEN: u16 = 16; @@ -332,7 +333,7 @@ pub struct DCERPCState { pub header: Option, pub bind: Option, pub bindack: Option, - pub transactions: Vec, + pub transactions: VecDeque, pub buffer_ts: Vec, pub buffer_tc: Vec, pub pad: u8, @@ -357,7 +358,7 @@ impl DCERPCState { header: None, bind: None, bindack: None, - transactions: Vec::new(), + transactions: VecDeque::new(), buffer_ts: Vec::new(), buffer_tc: Vec::new(), pad: 0, @@ -740,7 +741,7 @@ impl DCERPCState { sc_app_layer_parser_trigger_raw_stream_reassembly(flow, core::STREAM_TOSERVER.into()); } tx.frag_cnt_ts = 1; - self.transactions.push(tx); + self.transactions.push_back(tx); // Bytes parsed with `parse_dcerpc_bind` + (bytes parsed per bindctxitem [44] * number // of bindctxitems) (input.len() - leftover_bytes.len()) as i32 + retval * numctxitems as i32 @@ -921,7 +922,7 @@ impl DCERPCState { tx.ctxid = request.ctxid; tx.opnum = request.opnum; tx.first_request_seen = request.first_request_seen; - self.transactions.push(tx); + self.transactions.push_back(tx); } } let parsed = self.handle_common_stub( @@ -1064,8 +1065,8 @@ impl DCERPCState { } else { let mut tx = self.create_tx(current_call_id); tx.resp_cmd = x; - self.transactions.push(tx); - self.transactions.last_mut().unwrap() + self.transactions.push_back(tx); + self.transactions.back_mut().unwrap() }; tx.resp_done = true; tx.frag_cnt_tc = 1; @@ -1090,7 +1091,7 @@ impl DCERPCState { None => { let mut tx = self.create_tx(current_call_id); tx.resp_cmd = x; - self.transactions.push(tx); + self.transactions.push_back(tx); } }; retval = self.handle_common_stub( diff --git a/rust/src/dns/dns.rs b/rust/src/dns/dns.rs index 4b09cc2988..31add6dd64 100644 --- a/rust/src/dns/dns.rs +++ b/rust/src/dns/dns.rs @@ -428,7 +428,8 @@ impl DNSState { pub fn new_tcp() -> DNSState { return DNSState{ tx_id: 0, - transactions: VecDeque::new(), + transactions: VecDeque + ::new(), config: None, gap: false, };