mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Fix segfault if when statement's RHS is unitialized.
If it is ever assigned a value, the body of the when can be triggered as usual. Addresses BIT-1176.
This commit is contained in:
parent
432744fde4
commit
1f7facda5b
3 changed files with 71 additions and 1 deletions
|
@ -206,7 +206,7 @@ bool Trigger::Eval()
|
|||
return false;
|
||||
}
|
||||
|
||||
if ( v->IsZero() )
|
||||
if ( ! v || v->IsZero() )
|
||||
{
|
||||
// Not true. Perhaps next time...
|
||||
DBG_LOG(DBG_NOTIFIERS, "%s: trigger condition is false", Name());
|
||||
|
|
38
testing/btest/Baseline/language.when-unitialized-rhs/out
Normal file
38
testing/btest/Baseline/language.when-unitialized-rhs/out
Normal file
|
@ -0,0 +1,38 @@
|
|||
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.when-unitialized-rhs/when-unitialized-rhs.bro, line 9: value used but not set (crashMe)
|
||||
error in /Users/jsiwek/Projects/bro/bro/testing/btest/.tmp/language.when-unitialized-rhs/when-unitialized-rhs.bro, line 14: value used but not set (x)
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
2nd when stmt executing, 999
|
||||
1st when stmt executing, not anymore you don't
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
20
|
||||
21
|
||||
22
|
||||
23
|
||||
24
|
||||
25
|
||||
26
|
||||
27
|
||||
28
|
||||
29
|
||||
30
|
||||
31
|
||||
32
|
||||
33
|
||||
34
|
32
testing/btest/language/when-unitialized-rhs.bro
Normal file
32
testing/btest/language/when-unitialized-rhs.bro
Normal file
|
@ -0,0 +1,32 @@
|
|||
# @TEST-EXEC: bro -b -r $TRACES/wikipedia.trace %INPUT >out 2>&1
|
||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||
|
||||
global crashMe: function(): string;
|
||||
global x: int;
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
when( local result = crashMe() )
|
||||
{
|
||||
print "1st when stmt executing", result;
|
||||
}
|
||||
|
||||
when( local other_result = x )
|
||||
{
|
||||
print "2nd when stmt executing", other_result;
|
||||
}
|
||||
}
|
||||
|
||||
global conn_count = 0;
|
||||
|
||||
event new_connection(c: connection)
|
||||
{
|
||||
++conn_count;
|
||||
print conn_count;
|
||||
|
||||
if ( conn_count == 10 )
|
||||
{
|
||||
x = 999;
|
||||
crashMe = function(): string { return "not anymore you don't"; };
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue