mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Merge remote-tracking branch 'origin/topic/timw/2131-no-redef-segfault'
* origin/topic/timw/2131-no-redef-segfault: Return an error if redef'ing a variable without redef attribute
This commit is contained in:
commit
ac4b7f9f02
6 changed files with 44 additions and 1 deletions
4
CHANGES
4
CHANGES
|
@ -1,3 +1,7 @@
|
||||||
|
5.1.0-dev.292 | 2022-07-25 09:43:44 -0700
|
||||||
|
|
||||||
|
* Return an error if redef'ing a variable without redef attribute (Tim Wojtulewicz, Corelight)
|
||||||
|
|
||||||
5.1.0-dev.289 | 2022-07-21 11:54:12 -0700
|
5.1.0-dev.289 | 2022-07-21 11:54:12 -0700
|
||||||
|
|
||||||
* Add comments for specialized versions of util::split (Tim Wojtulewicz, Corelight)
|
* Add comments for specialized versions of util::split (Tim Wojtulewicz, Corelight)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
5.1.0-dev.289
|
5.1.0-dev.292
|
||||||
|
|
|
@ -223,6 +223,12 @@ static void make_var(const IDPtr& id, TypePtr t, InitClass c, ExprPtr init,
|
||||||
id->Warn("redefinition requires \"redef\"", redef_obj, true);
|
id->Warn("redefinition requires \"redef\"", redef_obj, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if ( dt == VAR_REDEF && ! id->IsRedefinable() )
|
||||||
|
{
|
||||||
|
id->Error("cannot redefine a variable not marked with &redef", init.get());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
else if ( dt != VAR_REDEF || init || ! attr )
|
else if ( dt != VAR_REDEF || init || ! attr )
|
||||||
{
|
{
|
||||||
if ( IsFunc(id->GetType()->Tag()) )
|
if ( IsFunc(id->GetType()->Tag()) )
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
error in <...>/redef-global-function.zeek, line 22 and <command line>, line 1: cannot redefine a variable not marked with &redef (funca)
|
|
@ -0,0 +1,2 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
func2()
|
29
testing/btest/language/redef-global-function.zeek
Normal file
29
testing/btest/language/redef-global-function.zeek
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# @TEST-EXEC: zeek -b %INPUT -e "redef funcb = func2;" > out
|
||||||
|
# @TEST-EXEC-FAIL: zeek -b %INPUT -e "redef funca = func2;" >> out
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff out
|
||||||
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff .stderr
|
||||||
|
|
||||||
|
export {
|
||||||
|
global func1: function();
|
||||||
|
global func2: function();
|
||||||
|
}
|
||||||
|
|
||||||
|
function func1()
|
||||||
|
{
|
||||||
|
print "func1()";
|
||||||
|
}
|
||||||
|
|
||||||
|
function func2()
|
||||||
|
{
|
||||||
|
print "func2()";
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
global funca = func1;
|
||||||
|
global funcb = func1 &redef;
|
||||||
|
}
|
||||||
|
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
funcb();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue