mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'htonl/weird_segfault'
* htonl/weird_segfault: Add btest test case Fix typo Fix segfault with incomplete connection
This commit is contained in:
commit
c1b2989035
5 changed files with 38 additions and 1 deletions
10
CHANGES
10
CHANGES
|
@ -1,3 +1,13 @@
|
||||||
|
4.1.0-dev.760 | 2021-06-27 10:46:01 -0700
|
||||||
|
|
||||||
|
* Add btest test case (Luke Cesarz)
|
||||||
|
|
||||||
|
* Fix typo (Luke Cesarz)
|
||||||
|
|
||||||
|
* Fix segfault with incomplete connection
|
||||||
|
|
||||||
|
Add required HasField check before GetFieldAs call (Luke Cesarz)
|
||||||
|
|
||||||
4.1.0-dev.755 | 2021-06-23 13:53:54 -0700
|
4.1.0-dev.755 | 2021-06-23 13:53:54 -0700
|
||||||
|
|
||||||
* Call brew update-reset in ci/macos/prepare.sh
|
* Call brew update-reset in ci/macos/prepare.sh
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.1.0-dev.755
|
4.1.0-dev.760
|
||||||
|
|
|
@ -380,6 +380,10 @@ bool Reporter::PermitFlowWeird(const char* name,
|
||||||
|
|
||||||
bool Reporter::PermitExpiredConnWeird(const char* name, const RecordVal& conn_id)
|
bool Reporter::PermitExpiredConnWeird(const char* name, const RecordVal& conn_id)
|
||||||
{
|
{
|
||||||
|
if ( !conn_id.HasField("orig_h") || !conn_id.HasField("resp_h") ||
|
||||||
|
!conn_id.HasField("orig_p") || !conn_id.HasField("resp_p") )
|
||||||
|
return false;
|
||||||
|
|
||||||
auto conn_tuple = std::make_tuple(conn_id.GetFieldAs<AddrVal>("orig_h"),
|
auto conn_tuple = std::make_tuple(conn_id.GetFieldAs<AddrVal>("orig_h"),
|
||||||
conn_id.GetFieldAs<AddrVal>("resp_h"),
|
conn_id.GetFieldAs<AddrVal>("resp_h"),
|
||||||
conn_id.GetFieldAs<PortVal>("orig_p")->Port(),
|
conn_id.GetFieldAs<PortVal>("orig_p")->Port(),
|
||||||
|
|
12
src/Val.h
12
src/Val.h
|
@ -1202,6 +1202,18 @@ public:
|
||||||
return (*record_val)[field] ? true : false;
|
return (*record_val)[field] ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given field is in the record, false if
|
||||||
|
* it's missing.
|
||||||
|
* @param field The field name to retrieve.
|
||||||
|
* @return Whether there's a value for the given field name.
|
||||||
|
*/
|
||||||
|
bool HasField(const char *field) const
|
||||||
|
{
|
||||||
|
int idx = GetType()->AsRecordType()->FieldOffset(field);
|
||||||
|
return HasField(idx);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value of a given field index.
|
* Returns the value of a given field index.
|
||||||
* @param field The field index to retrieve.
|
* @param field The field index to retrieve.
|
||||||
|
|
11
testing/btest/core/empty_conn_weird.zeek
Normal file
11
testing/btest/core/empty_conn_weird.zeek
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: zeek -b %INPUT
|
||||||
|
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
local x: connection;
|
||||||
|
x$uid = "uid";
|
||||||
|
|
||||||
|
Reporter::conn_weird("foo", x);
|
||||||
|
print "done";
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue