mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix &raw_output and enable_raw_output interpretation of NUL characters
When using a `print` statement to write to a file that has raw output enabled, NUL characters in string are no longer interpreted into "\0", no newline is appended afterwards, and each argument to `print` is written to the file without any additional separation. (Re)Assigning to identifiers with the &raw_output attribute should also now correctly apply the attribute to the file value being assigned. Note that the write_file BiF should already be capable of raw string data to a file, expect it bypasses the print_hook event. Addresses #474
This commit is contained in:
parent
6c806b0bce
commit
648e1bda26
12 changed files with 108 additions and 21 deletions
21
src/Desc.cc
21
src/Desc.cc
|
@ -174,15 +174,20 @@ void ODesc::AddBytes(const BroString* s)
|
|||
{
|
||||
if ( IsReadable() )
|
||||
{
|
||||
int render_style = BroString::EXPANDED_STRING;
|
||||
if ( Style() == ALTERNATIVE_STYLE )
|
||||
// Only change NULs, since we can't in any case
|
||||
// cope with them.
|
||||
render_style = BroString::ESC_NULL;
|
||||
if ( Style() == RAW_STYLE )
|
||||
AddBytes(reinterpret_cast<const char*>(s->Bytes()), s->Len());
|
||||
else
|
||||
{
|
||||
int render_style = BroString::EXPANDED_STRING;
|
||||
if ( Style() == ALTERNATIVE_STYLE )
|
||||
// Only change NULs, since we can't in any case
|
||||
// cope with them.
|
||||
render_style = BroString::ESC_NULL;
|
||||
|
||||
const char* str = s->Render(render_style);
|
||||
Add(str);
|
||||
delete [] str;
|
||||
const char* str = s->Render(render_style);
|
||||
Add(str);
|
||||
delete [] str;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue