Fix dump_packet & dump_current_packet ignores file_name

This fixes an issue where `dump_packet` and `dump_current_packet` ignores the `file_name` parameter if `addl_pkt_dumper` is already pointing to some file (doesn't matter which file...)

http://mailman.icsi.berkeley.edu/pipermail/bro/2018-May/013184.html
This commit is contained in:
Assaf Morami 2018-05-08 15:46:18 +03:00 committed by GitHub
parent 091d1e163f
commit f35eae2e7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,6 +29,7 @@ using namespace std;
TableType* var_sizes;
static iosource::PktDumper* addl_pkt_dumper = 0;
static StringVal* open_file_dumper;
bro_int_t parse_int(const char*& fmt)
{
@ -3288,10 +3289,19 @@ function dump_current_packet%(file_name: string%) : bool
return new Val(0, TYPE_BOOL);
if ( ! addl_pkt_dumper )
{
addl_pkt_dumper = iosource_mgr->OpenPktDumper(file_name->CheckString(), true);
{
else if ( addl_pkt_dumper && open_file_dumper != file_name)
{
addl_pkt_dumper->Close();
addl_pkt_dumper = iosource_mgr->OpenPktDumper(file_name->CheckString(), true);
}
// else if (addl_pkt_dumper && open_file_dumper == file_name) do nothing
if ( addl_pkt_dumper )
{
open_file_dumper = file_name;
addl_pkt_dumper->Dump(pkt);
}
@ -3363,10 +3373,20 @@ function get_current_packet_header%(%) : raw_pkt_hdr
function dump_packet%(pkt: pcap_packet, file_name: string%) : bool
%{
if ( ! addl_pkt_dumper )
{
addl_pkt_dumper = iosource_mgr->OpenPktDumper(file_name->CheckString(), true);
{
else if ( addl_pkt_dumper && open_file_dumper != file_name)
{
addl_pkt_dumper->Close();
addl_pkt_dumper = iosource_mgr->OpenPktDumper(file_name->CheckString(), true);
}
// else if (addl_pkt_dumper && open_file_dumper == file_name) do nothing
if ( addl_pkt_dumper )
{
open_file_dumper = file_name;
pkt_timeval ts;
uint32 caplen, len, link_type;
u_char *data;