]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
rdp: fix transaction id
authorJason Ish <jason.ish@oisf.net>
Tue, 16 Nov 2021 23:52:58 +0000 (17:52 -0600)
committerVictor Julien <vjulien@oisf.net>
Mon, 22 Nov 2021 09:24:05 +0000 (10:24 +0100)
By our convention the transaction ID is incremented then applied
to the new transaction. And the generic transaction iterator
requires this behaviour.

rust/src/rdp/rdp.rs

index 58083cfaff2a726d057a3e9d1167d2fe8a47407b..4e60e7b389fce85ee50d907b723bfbbd61e0986f 100644 (file)
@@ -155,8 +155,8 @@ impl RdpState {
     }
 
     fn new_tx(&mut self, item: RdpTransactionItem) -> RdpTransaction {
-        let tx = RdpTransaction::new(self.next_id, item);
         self.next_id += 1;
+        let tx = RdpTransaction::new(self.next_id, item);
         return tx;
     }
 
@@ -602,8 +602,8 @@ mod tests {
         state.transactions.push(tx0);
         state.transactions.push(tx1);
         assert_eq!(2, state.transactions.len());
-        assert_eq!(0, state.transactions[0].id);
-        assert_eq!(1, state.transactions[1].id);
+        assert_eq!(1, state.transactions[0].id);
+        assert_eq!(2, state.transactions[1].id);
         assert_eq!(false, state.tls_parsing);
         assert_eq!(false, state.bypass_parsing);
     }
@@ -626,7 +626,7 @@ mod tests {
         state.transactions.push(tx0);
         state.transactions.push(tx1);
         state.transactions.push(tx2);
-        assert_eq!(Some(&state.transactions[1]), state.get_tx(1));
+        assert_eq!(Some(&state.transactions[1]), state.get_tx(2));
     }
 
     #[test]
@@ -650,8 +650,8 @@ mod tests {
         state.free_tx(1);
         assert_eq!(3, state.next_id);
         assert_eq!(2, state.transactions.len());
-        assert_eq!(0, state.transactions[0].id);
-        assert_eq!(2, state.transactions[1].id);
+        assert_eq!(2, state.transactions[0].id);
+        assert_eq!(3, state.transactions[1].id);
         assert_eq!(None, state.get_tx(1));
     }
 }