mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fix potential nullptr deref in Spicy plugin runtime
If we added a file but the other side of the connection had already run into a protocol violation and shut down we could previously have dereferenced a null cookie. This patch fixes the code so it now throws in such scenarios.
This commit is contained in:
parent
0028ba320d
commit
93c201df57
1 changed files with 8 additions and 6 deletions
|
@ -285,12 +285,14 @@ void rt::debug(const Cookie& cookie, const std::string& msg) {
|
|||
inline rt::cookie::FileStateStack* _file_state_stack(rt::Cookie* cookie) {
|
||||
auto _ = hilti::rt::profiler::start("zeek/rt/file_state_stack");
|
||||
|
||||
if ( auto c = cookie->protocol )
|
||||
return c->is_orig ? &c->fstate_orig : &c->fstate_resp;
|
||||
else if ( auto f = cookie->file )
|
||||
return &f->fstate;
|
||||
else
|
||||
throw rt::ValueUnavailable("no current connection or file available");
|
||||
if ( cookie ) {
|
||||
if ( auto c = cookie->protocol )
|
||||
return c->is_orig ? &c->fstate_orig : &c->fstate_resp;
|
||||
else if ( auto f = cookie->file )
|
||||
return &f->fstate;
|
||||
}
|
||||
|
||||
throw rt::ValueUnavailable("no current connection or file available");
|
||||
}
|
||||
|
||||
inline const rt::cookie::FileState* _file_state(rt::Cookie* cookie, std::optional<std::string> fid) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue