]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/snmp: fix selection of v1/v2c parser
authorPierre Chifflier <chifflier@wzdftpd.net>
Thu, 14 Feb 2019 16:11:50 +0000 (17:11 +0100)
committerPierre Chifflier <chifflier@wzdftpd.net>
Thu, 6 Jun 2019 08:15:59 +0000 (10:15 +0200)
rust/src/snmp/snmp.rs

index 28508bc6ddf67c314f5710dbe449099f0c71cdb8..3f8f6fd7482f1390fdeaa2949e5ffeb6595dcb1c 100644 (file)
@@ -133,7 +133,16 @@ impl SNMPState {
     }
 
     fn parse_v1_2(&mut self, i: &[u8], _direction: u8) -> i32 {
-        match parse_snmp_v1(i) {
+        let parser = match self.version {
+            1 => parse_snmp_v1,
+            2 => parse_snmp_v2c,
+            _ => {
+                SCLogInfo!("parse_snmp: invalid version {}", self.version);
+                self.set_event(SNMPEvent::MalformedData);
+                return -1;
+            }
+        };
+        match parser(i) {
             Ok((_rem,r)) => {
                 let mut tx = self.new_tx();
                 self.add_pdu_info(&r.pdu, &mut tx);
@@ -142,7 +151,7 @@ impl SNMPState {
                 0
             },
             _e => {
-                SCLogInfo!("parse_snmp_v1 failed: {:?}", _e);
+                SCLogInfo!("parse_snmp_v{} failed: {:?}", self.version, _e);
                 self.set_event(SNMPEvent::MalformedData);
                 -1
             },