From: Pierre Chifflier Date: Thu, 14 Feb 2019 16:11:50 +0000 (+0100) Subject: rust/snmp: fix selection of v1/v2c parser X-Git-Tag: suricata-5.0.0-rc1~422 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=031cbbe8689cccd34ae20707c19d9a578c1c011c;p=thirdparty%2Fsuricata.git rust/snmp: fix selection of v1/v2c parser --- diff --git a/rust/src/snmp/snmp.rs b/rust/src/snmp/snmp.rs index 28508bc6dd..3f8f6fd748 100644 --- a/rust/src/snmp/snmp.rs +++ b/rust/src/snmp/snmp.rs @@ -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 },