Merge remote-tracking branch 'origin/topic/jsiwek/bit-1176'

* origin/topic/jsiwek/bit-1176:
  Fix segfault if when statement's RHS is unitialized.

BIT-1176 #merged
This commit is contained in:
Robin Sommer 2014-10-31 16:29:42 -07:00
commit 78de5c17ef
5 changed files with 80 additions and 2 deletions

View file

@ -1,4 +1,12 @@
2.3-272 | 2014-10-31 16:29:42 -0700
* Fix segfault if when statement's RHS is unitialized. Addresses
BIT-1176. (Jon Siwek)
* Fix checking vector indices via "in". Addresses BIT-1280. (Jon
Siwek)
2.3-268 | 2014-10-31 12:12:22 -0500
* BIT-1283: Fix crash when using &encrypt. (Jon Siwek)

View file

@ -1 +1 @@
2.3-268
2.3-272

View file

@ -207,7 +207,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());

View 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

View 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"; };
}
}