mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'origin/master' into topic/robin/plugins
Thanks to git this merge was less troublesome that I was afraid it would be. Not all tests pass yet though (and file hashes have changed unfortunately). Conflicts: cmake doc/scripts/DocSourcesList.cmake scripts/base/init-bare.bro scripts/base/protocols/ftp/main.bro scripts/base/protocols/irc/dcc-send.bro scripts/test-all-policy.bro src/AnalyzerTags.h src/CMakeLists.txt src/analyzer/Analyzer.cc src/analyzer/protocol/file/File.cc src/analyzer/protocol/file/File.h src/analyzer/protocol/http/HTTP.cc src/analyzer/protocol/http/HTTP.h src/analyzer/protocol/mime/MIME.cc src/event.bif src/main.cc src/util-config.h.in testing/btest/Baseline/coverage.bare-load-baseline/canonified_loaded_scripts.log testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log testing/btest/Baseline/istate.events-ssl/receiver.http.log testing/btest/Baseline/istate.events-ssl/sender.http.log testing/btest/Baseline/istate.events/receiver.http.log testing/btest/Baseline/istate.events/sender.http.log
This commit is contained in:
commit
eb637f9f3e
411 changed files with 240276 additions and 161868 deletions
54
src/util.cc
54
src/util.cc
|
@ -872,6 +872,16 @@ const char* bro_path()
|
|||
return path;
|
||||
}
|
||||
|
||||
const char* bro_magic_path()
|
||||
{
|
||||
const char* path = getenv("BROMAGIC");
|
||||
|
||||
if ( ! path )
|
||||
path = BRO_MAGIC_INSTALL_PATH;
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
const char* bro_prefixes()
|
||||
{
|
||||
int len = 1; // room for \0
|
||||
|
@ -1401,6 +1411,31 @@ bool safe_write(int fd, const char* data, int len)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool safe_pwrite(int fd, const unsigned char* data, size_t len, size_t offset)
|
||||
{
|
||||
while ( len != 0 )
|
||||
{
|
||||
ssize_t n = pwrite(fd, data, len, offset);
|
||||
|
||||
if ( n < 0 )
|
||||
{
|
||||
if ( errno == EINTR )
|
||||
continue;
|
||||
|
||||
fprintf(stderr, "safe_write error: %d\n", errno);
|
||||
abort();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
data += n;
|
||||
offset +=n;
|
||||
len -= n;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void safe_close(int fd)
|
||||
{
|
||||
/*
|
||||
|
@ -1543,18 +1578,29 @@ void bro_init_magic(magic_t* cookie_ptr, int flags)
|
|||
if ( ! cookie_ptr || *cookie_ptr )
|
||||
return;
|
||||
|
||||
*cookie_ptr = magic_open(flags);
|
||||
*cookie_ptr = magic_open(flags|MAGIC_NO_CHECK_TOKENS);
|
||||
|
||||
// Use our custom database for mime types, but the default database
|
||||
// from libmagic for the verbose file type.
|
||||
const char* database = (flags & MAGIC_MIME) ? bro_magic_path() : 0;
|
||||
|
||||
if ( ! *cookie_ptr )
|
||||
{
|
||||
const char* err = magic_error(*cookie_ptr);
|
||||
reporter->Error("can't init libmagic: %s", err ? err : "unknown");
|
||||
if ( ! err )
|
||||
err = "unknown";
|
||||
|
||||
reporter->InternalError("can't init libmagic: %s", err);
|
||||
}
|
||||
|
||||
else if ( magic_load(*cookie_ptr, 0) < 0 )
|
||||
else if ( magic_load(*cookie_ptr, database) < 0 )
|
||||
{
|
||||
const char* err = magic_error(*cookie_ptr);
|
||||
reporter->Error("can't load magic file: %s", err ? err : "unknown");
|
||||
if ( ! err )
|
||||
err = "unknown";
|
||||
|
||||
const char* db_name = database ? database : "<default>";
|
||||
reporter->InternalError("can't load magic file %s: %s", db_name, err);
|
||||
magic_close(*cookie_ptr);
|
||||
*cookie_ptr = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue