Fix use-after-free in some cases of reassigning a table index.

Specifically observed when redef'ing the same index of a table that uses
subnets as indices, though the bug seems like it applies more generally
to anytime TableVal::Assign is provided with just the HashKey parameter
and not the index Val.

Addresses BIT-1202.
This commit is contained in:
Jon Siwek 2014-06-10 13:38:32 -05:00
parent c289a2743b
commit e616554ab8
3 changed files with 29 additions and 3 deletions

View file

@ -0,0 +1,4 @@
{
[3.0.0.0/8] = 2.0.0.0/8
}
2.0.0.0/8

View file

@ -0,0 +1,17 @@
# @TEST-EXEC: bro -b %INPUT >out
# @TEST-EXEC: btest-diff out
const my_table: table[subnet] of subnet &redef;
redef my_table[3.0.0.0/8] = 1.0.0.0/8;
redef my_table[3.0.0.0/8] = 2.0.0.0/8;
# The above is basically a shorthand for:
# redef my_table += { [3.0.0.0/8] = 1.0.0.0/8 };
# redef my_table += { [3.0.0.0/8] = 2.0.0.0/8 };
event bro_init()
{
print my_table;
print my_table[3.0.0.0/8];
}