mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00

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
23 lines
568 B
Text
23 lines
568 B
Text
# Files which enable raw output via the BiF shouldn't interpret NUL characters
|
|
# in strings that are `print`ed to it.
|
|
|
|
# @TEST-EXEC: bro %INPUT
|
|
# @TEST-EXEC: tr '\000' 'X' <myfile >output
|
|
# @TEST-EXEC: btest-diff output
|
|
# @TEST-EXEC: cmp myfile hookfile
|
|
|
|
event bro_init()
|
|
{
|
|
local myfile: file;
|
|
myfile = open("myfile");
|
|
enable_raw_output(myfile);
|
|
print myfile, "hello\x00world", "hi";
|
|
close(myfile);
|
|
}
|
|
|
|
event print_hook(f: file, s: string)
|
|
{
|
|
local hookfile = open("hookfile");
|
|
write_file(hookfile, s);
|
|
close(hookfile);
|
|
}
|