From ceab58c17ebebbd2f4a39b3113c5bef6cd65671f Mon Sep 17 00:00:00 2001 From: Vlad Grigorescu Date: Wed, 2 May 2018 15:39:43 -0500 Subject: [PATCH] Make BinPAC exception handling more consistent --- src/analyzer/protocol/krb/KRB.cc | 2 +- src/analyzer/protocol/krb/KRB_TCP.cc | 2 +- src/analyzer/protocol/mysql/MySQL.cc | 2 +- src/analyzer/protocol/ncp/NCP.cc | 2 +- src/analyzer/protocol/sip/SIP_TCP.cc | 3 +-- src/analyzer/protocol/snmp/SNMP.cc | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/analyzer/protocol/krb/KRB.cc b/src/analyzer/protocol/krb/KRB.cc index 0a123c3beb..ba7dbd9ccd 100644 --- a/src/analyzer/protocol/krb/KRB.cc +++ b/src/analyzer/protocol/krb/KRB.cc @@ -33,7 +33,7 @@ void KRB_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, } catch ( const binpac::Exception& e ) { - ProtocolViolation(e.c_msg()); + ProtocolViolation(fmt("Binpac exception: %s", e.c_msg())); } } diff --git a/src/analyzer/protocol/krb/KRB_TCP.cc b/src/analyzer/protocol/krb/KRB_TCP.cc index 865b3de1e4..27e964f2d7 100644 --- a/src/analyzer/protocol/krb/KRB_TCP.cc +++ b/src/analyzer/protocol/krb/KRB_TCP.cc @@ -53,7 +53,7 @@ void KRB_Analyzer::DeliverStream(int len, const u_char* data, bool orig) } catch ( const binpac::Exception& e ) { - ProtocolViolation(e.c_msg()); + ProtocolViolation(fmt("Binpac exception: %s", e.c_msg())); } } diff --git a/src/analyzer/protocol/mysql/MySQL.cc b/src/analyzer/protocol/mysql/MySQL.cc index bfa2eb518b..af874ff5c2 100644 --- a/src/analyzer/protocol/mysql/MySQL.cc +++ b/src/analyzer/protocol/mysql/MySQL.cc @@ -53,7 +53,7 @@ void MySQL_Analyzer::DeliverStream(int len, const u_char* data, bool orig) } catch ( const binpac::Exception& e ) { - reporter->Weird(e.msg().c_str()); + ProtocolViolation(fmt("Binpac exception: %s", e.c_msg())); } } diff --git a/src/analyzer/protocol/ncp/NCP.cc b/src/analyzer/protocol/ncp/NCP.cc index 4605ad2bca..add7841908 100644 --- a/src/analyzer/protocol/ncp/NCP.cc +++ b/src/analyzer/protocol/ncp/NCP.cc @@ -40,7 +40,7 @@ void NCP_Session::Deliver(int is_orig, int len, const u_char* data) } catch ( const binpac::Exception& e ) { - analyzer->Weird(e.msg().c_str()); + analyzer->ProtocolViolation(fmt("Binpac exception: %s", e.c_msg())); } } diff --git a/src/analyzer/protocol/sip/SIP_TCP.cc b/src/analyzer/protocol/sip/SIP_TCP.cc index 464c650bd9..23cc654fdb 100644 --- a/src/analyzer/protocol/sip/SIP_TCP.cc +++ b/src/analyzer/protocol/sip/SIP_TCP.cc @@ -55,8 +55,7 @@ void SIP_Analyzer::DeliverStream(int len, const u_char* data, bool orig) } catch ( const binpac::Exception& e ) { - printf("BinPAC Exception: %s\n", e.c_msg()); - ProtocolViolation(e.c_msg()); + ProtocolViolation(fmt("Binpac exception: %s", e.c_msg())); } } diff --git a/src/analyzer/protocol/snmp/SNMP.cc b/src/analyzer/protocol/snmp/SNMP.cc index 36282087fa..c34c4d596e 100644 --- a/src/analyzer/protocol/snmp/SNMP.cc +++ b/src/analyzer/protocol/snmp/SNMP.cc @@ -35,6 +35,6 @@ void SNMP_Analyzer::DeliverPacket(int len, const u_char* data, bool orig, } catch ( const binpac::Exception& e ) { - ProtocolViolation(e.c_msg()); + ProtocolViolation(fmt("Binpac exception: %s", e.c_msg())); } }