mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 19:48:20 +00:00
session/Manager: Emit explicit errors for FindConnection() with proto=65535
We silently broke users constructing conn_id records manually and subsequently using them with lookup_connection() or connection_exists(). This is an attempt to at least report a runtime error about the situation so it doesn't go completely unnoticed.
This commit is contained in:
parent
ec0a85f553
commit
17836ef7d9
3 changed files with 76 additions and 1 deletions
|
@ -9,6 +9,8 @@
|
|||
#include <cstdlib>
|
||||
|
||||
#include "zeek/Conn.h"
|
||||
#include "zeek/Func.h"
|
||||
#include "zeek/IP.h"
|
||||
#include "zeek/NetVar.h"
|
||||
#include "zeek/Reporter.h"
|
||||
#include "zeek/RuleMatcher.h"
|
||||
|
@ -18,6 +20,7 @@
|
|||
#include "zeek/packet_analysis/Manager.h"
|
||||
#include "zeek/session/Session.h"
|
||||
#include "zeek/telemetry/Manager.h"
|
||||
#include "zeek/util.h"
|
||||
|
||||
zeek::session::Manager* zeek::session_mgr = nullptr;
|
||||
|
||||
|
@ -89,8 +92,15 @@ void Manager::Done() {}
|
|||
Connection* Manager::FindConnection(Val* v) {
|
||||
zeek::detail::ConnKey conn_key(v);
|
||||
|
||||
if ( ! conn_key.valid )
|
||||
if ( ! conn_key.Valid() ) {
|
||||
// Produce a loud error for invalid script-layer conn_id records.
|
||||
const char* extra = "";
|
||||
if ( conn_key.transport == UNKNOWN_IP_PROTO )
|
||||
extra = ": the proto field has the \"unknown\" 65535 value. Did you forget to set it?";
|
||||
|
||||
zeek::emit_builtin_error(zeek::util::fmt("invalid connection ID record encountered%s", extra));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return FindConnection(conn_key);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue