mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 11:08:20 +00:00
Merge remote-tracking branch 'origin/topic/robin/event-args'
* origin/topic/robin/event-args: Fix assignments to event arguments becoming visible to subsequent handlers.
This commit is contained in:
commit
57b3e21de7
6 changed files with 48 additions and 6 deletions
5
CHANGES
5
CHANGES
|
@ -1,4 +1,9 @@
|
||||||
|
|
||||||
|
2.5-352 | 2017-11-21 13:21:51 -0600
|
||||||
|
|
||||||
|
* Fix assignments to event arguments becoming visible to subsequent
|
||||||
|
handlers. (Robin Sommer)
|
||||||
|
|
||||||
2.5-350 | 2017-11-21 12:19:28 -0600
|
2.5-350 | 2017-11-21 12:19:28 -0600
|
||||||
|
|
||||||
* Add HookReporter plugin hook function.
|
* Add HookReporter plugin hook function.
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.5-350
|
2.5-352
|
||||||
|
|
23
src/Func.cc
23
src/Func.cc
|
@ -383,11 +383,7 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
|
||||||
FType()->FlavorString().c_str(), d.Description());
|
FType()->FlavorString().c_str(), d.Description());
|
||||||
}
|
}
|
||||||
|
|
||||||
loop_over_list(*args, i)
|
|
||||||
f->SetElement(i, (*args)[i]);
|
|
||||||
|
|
||||||
stmt_flow_type flow = FLOW_NEXT;
|
stmt_flow_type flow = FLOW_NEXT;
|
||||||
|
|
||||||
Val* result = 0;
|
Val* result = 0;
|
||||||
|
|
||||||
for ( size_t i = 0; i < bodies.size(); ++i )
|
for ( size_t i = 0; i < bodies.size(); ++i )
|
||||||
|
@ -397,6 +393,20 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
|
||||||
bodies[i].stmts->GetLocationInfo());
|
bodies[i].stmts->GetLocationInfo());
|
||||||
|
|
||||||
Unref(result);
|
Unref(result);
|
||||||
|
|
||||||
|
loop_over_list(*args, j)
|
||||||
|
{
|
||||||
|
Val* arg = (*args)[j];
|
||||||
|
|
||||||
|
if ( f->NthElement(j) != arg )
|
||||||
|
{
|
||||||
|
// Either not yet set, or somebody reassigned
|
||||||
|
// the frame slot.
|
||||||
|
Ref(arg);
|
||||||
|
f->SetElement(j, arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
f->Reset(args->length());
|
f->Reset(args->length());
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -434,6 +444,11 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We have an extra Ref for each argument (so that they don't get
|
||||||
|
// deleted between bodies), release that.
|
||||||
|
loop_over_list(*args, k)
|
||||||
|
Unref((*args)[k]);
|
||||||
|
|
||||||
if ( Flavor() == FUNC_FLAVOR_HOOK )
|
if ( Flavor() == FUNC_FLAVOR_HOOK )
|
||||||
{
|
{
|
||||||
if ( ! result )
|
if ( ! result )
|
||||||
|
|
2
testing/btest/Baseline/core.event-arg-reuse/output
Normal file
2
testing/btest/Baseline/core.event-arg-reuse/output
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
f1, 2
|
||||||
|
f2, 1
|
|
@ -1,3 +1,3 @@
|
||||||
[orig_h=141.142.220.118, orig_p=35642/tcp, resp_h=208.80.152.2, resp_p=80/tcp]
|
[orig_h=141.142.220.118, orig_p=35642/tcp, resp_h=208.80.152.2, resp_p=80/tcp]
|
||||||
works
|
works
|
||||||
GET /images/wikimedia-button.png HTTP/1.1\x0d\x0aHost: meta.wikimedia.org\x0d\x0aUser-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Geck...
|
GET /images/wikimedia-button.png HTTP/1.1\x0d\x0aHost: meta.wikimedia.org\x0d\x0aUser-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110303 Ubuntu/10.04 (lucid) Firefox/3.6.15\x0d\x0aAccept: image/png,image/*;q=0.8,*/*;q=0.5\x0d\x0aAccept-Language: en-us,en;q=0.5\x0d\x0aAccept-Encoding: gzip,deflate\x0d\x0aAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\x0d\x0aKeep-Alive: 115\x0d\x0aConnection: keep-alive\x0d\x0aReferer: http://www.wikipedia.org/\x0d\x0aIf-Modified-Since: Fri, 05 Nov 2010 16:00:03 GMT\x0d\x0aIf-None-Match: "97a-494505e0c46c0"\x0d\x0aCache-Control: max-age=0\x0d\x0a\x0d\x0a
|
||||||
|
|
20
testing/btest/core/event-arg-reuse.bro
Normal file
20
testing/btest/core/event-arg-reuse.bro
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# @TEST-DOC: Check that assignment to event parameters isn't visible to other handlers.
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: bro -b %INPUT >output
|
||||||
|
# @TEST-EXEC: btest-diff output
|
||||||
|
|
||||||
|
event f(a: int) &priority=5
|
||||||
|
{
|
||||||
|
a = 2;
|
||||||
|
print "f1", a;
|
||||||
|
}
|
||||||
|
|
||||||
|
event f(a: int) &priority=-5
|
||||||
|
{
|
||||||
|
print "f2", a;
|
||||||
|
}
|
||||||
|
|
||||||
|
event bro_init()
|
||||||
|
{
|
||||||
|
event f(1);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue