mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 09:08:20 +00:00
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:
parent
091d1e163f
commit
f35eae2e7e
1 changed files with 20 additions and 0 deletions
20
src/bro.bif
20
src/bro.bif
|
@ -29,6 +29,7 @@ using namespace std;
|
||||||
TableType* var_sizes;
|
TableType* var_sizes;
|
||||||
|
|
||||||
static iosource::PktDumper* addl_pkt_dumper = 0;
|
static iosource::PktDumper* addl_pkt_dumper = 0;
|
||||||
|
static StringVal* open_file_dumper;
|
||||||
|
|
||||||
bro_int_t parse_int(const char*& fmt)
|
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);
|
return new Val(0, TYPE_BOOL);
|
||||||
|
|
||||||
if ( ! addl_pkt_dumper )
|
if ( ! addl_pkt_dumper )
|
||||||
|
{
|
||||||
addl_pkt_dumper = iosource_mgr->OpenPktDumper(file_name->CheckString(), true);
|
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 )
|
if ( addl_pkt_dumper )
|
||||||
{
|
{
|
||||||
|
open_file_dumper = file_name;
|
||||||
addl_pkt_dumper->Dump(pkt);
|
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
|
function dump_packet%(pkt: pcap_packet, file_name: string%) : bool
|
||||||
%{
|
%{
|
||||||
if ( ! addl_pkt_dumper )
|
if ( ! addl_pkt_dumper )
|
||||||
|
{
|
||||||
addl_pkt_dumper = iosource_mgr->OpenPktDumper(file_name->CheckString(), true);
|
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 )
|
if ( addl_pkt_dumper )
|
||||||
{
|
{
|
||||||
|
open_file_dumper = file_name;
|
||||||
|
|
||||||
pkt_timeval ts;
|
pkt_timeval ts;
|
||||||
uint32 caplen, len, link_type;
|
uint32 caplen, len, link_type;
|
||||||
u_char *data;
|
u_char *data;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue