Merge remote-tracking branch 'origin/master' into topic/vladg/mysql

This commit is contained in:
Vlad Grigorescu 2014-10-31 16:46:07 -04:00
commit 743d388be8
28 changed files with 118 additions and 53 deletions

26
CHANGES
View file

@ -1,4 +1,30 @@
2.3-268 | 2014-10-31 12:12:22 -0500
* BIT-1283: Fix crash when using &encrypt. (Jon Siwek)
2.3-267 | 2014-10-31 10:35:02 -0500
* BIT-1284: Allow arbitrary when statement timeout expressions
(Jon Siwek)
2.3-266 | 2014-10-31 09:21:28 -0500
* BIT-1166: Add configure options to fine tune local state dirs used
by BroControl. (Jon Siwek)
2.3-264 | 2014-10-30 13:25:57 -0500
* Fix some minor Coverity Scan complaints. (Jon Siwek)
2.3-263 | 2014-10-28 15:09:10 -0500
* Fix checking of fwrite return values (Johanna Amann)
2.3-260 | 2014-10-27 12:54:17 -0500
* Fix errors/warnings when compiling with -std=c++11 (Jon Siwek)
2.3-259 | 2014-10-27 10:04:04 -0500 2.3-259 | 2014-10-27 10:04:04 -0500
* Documentation fixes. (Vicente Jimenez Aguilar and Stefano Azzalini) * Documentation fixes. (Vicente Jimenez Aguilar and Stefano Azzalini)

View file

@ -1 +1 @@
2.3-259 2.3-268

@ -1 +1 @@
Subproject commit 2b13bfcc941018c76f74b81a6e74e5e4e723c747 Subproject commit 39e865dec9611b9b53b609cbc8df519cebae0a1e

16
configure vendored
View file

@ -24,6 +24,13 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--prefix=PREFIX installation directory [/usr/local/bro] --prefix=PREFIX installation directory [/usr/local/bro]
--scriptdir=PATH root installation directory for Bro scripts --scriptdir=PATH root installation directory for Bro scripts
[PREFIX/share/bro] [PREFIX/share/bro]
--localstatedir=PATH when using BroControl, path to store log files
and run-time data (within log/ and spool/ subdirs)
[PREFIX]
--spooldir=PATH when using BroControl, path to store run-time data
[PREFIX/spool]
--logdir=PATH when using BroControl, path to store log file
[PREFIX/logs]
--conf-files-dir=PATH config files installation directory [PREFIX/etc] --conf-files-dir=PATH config files installation directory [PREFIX/etc]
Optional Features: Optional Features:
@ -144,6 +151,15 @@ while [ $# -ne 0 ]; do
append_cache_entry BRO_ETC_INSTALL_DIR PATH $optarg append_cache_entry BRO_ETC_INSTALL_DIR PATH $optarg
user_set_conffilesdir="true" user_set_conffilesdir="true"
;; ;;
--localstatedir=*)
append_cache_entry BRO_LOCAL_STATE_DIR PATH $optarg
;;
--spooldir=*)
append_cache_entry BRO_SPOOL_DIR PATH $optarg
;;
--logdir=*)
append_cache_entry BRO_LOG_DIR PATH $optarg
;;
--enable-debug) --enable-debug)
append_cache_entry ENABLE_DEBUG BOOL true append_cache_entry ENABLE_DEBUG BOOL true
;; ;;

View file

@ -16,6 +16,7 @@ the 'dpkg-dev' package, please install it first.
} }
prefix=/opt/bro prefix=/opt/bro
localstatedir=/var/opt/bro
# During the packaging process, `dpkg-shlibs` will fail if used on a library # During the packaging process, `dpkg-shlibs` will fail if used on a library
# that links to other internal/project libraries unless an RPATH is used or # that links to other internal/project libraries unless an RPATH is used or
@ -31,7 +32,7 @@ cd ..
( cd build && make package ) ( cd build && make package )
# Full Bro package # Full Bro package
./configure --prefix=${prefix} --pkg-name-prefix=Bro --binary-package ./configure --prefix=${prefix} --localstatedir=${localstatedir} --pkg-name-prefix=Bro --binary-package
( cd build && make package ) ( cd build && make package )
# Broccoli # Broccoli
@ -42,6 +43,6 @@ cd ../..
# Broctl # Broctl
cd aux/broctl cd aux/broctl
./configure --prefix=${prefix} --binary-package ./configure --prefix=${prefix} --localstatedir=${localstatedir} --binary-package
( cd build && make package && mv *.deb ../../../build/ ) ( cd build && make package && mv *.deb ../../../build/ )
cd ../.. cd ../..

View file

@ -15,6 +15,7 @@ the 'rpm-build' package, please install it first.
} }
prefix=/opt/bro prefix=/opt/bro
localstatedir=/var/opt/bro
cd .. cd ..
@ -24,7 +25,7 @@ cd ..
( cd build && make package ) ( cd build && make package )
# Full Bro package # Full Bro package
./configure --prefix=${prefix} --pkg-name-prefix=Bro --binary-package ./configure --prefix=${prefix} --localstatedir=${localstatedir} --pkg-name-prefix=Bro --binary-package
( cd build && make package ) ( cd build && make package )
# Broccoli # Broccoli
@ -35,6 +36,6 @@ cd ../..
# Broctl # Broctl
cd aux/broctl cd aux/broctl
./configure --prefix=${prefix} --binary-package ./configure --prefix=${prefix} --localstatedir=${localstatedir} --binary-package
( cd build && make package && mv *.rpm ../../../build/ ) ( cd build && make package && mv *.rpm ../../../build/ )
cd ../.. cd ../..

View file

@ -527,7 +527,7 @@ void BroFile::SetAttrs(Attributes* arg_attrs)
if ( ef->AttrExpr() ) if ( ef->AttrExpr() )
InitEncrypt(ef->AttrExpr()->ExprVal()->AsString()->CheckString()); InitEncrypt(ef->AttrExpr()->ExprVal()->AsString()->CheckString());
else else
InitEncrypt(log_encryption_key->AsString()->CheckString()); InitEncrypt(opt_internal_string("log_encryption_key")->CheckString());
} }
if ( attrs->FindAttr(ATTR_RAW_OUTPUT) ) if ( attrs->FindAttr(ATTR_RAW_OUTPUT) )
@ -708,10 +708,10 @@ void BroFile::InitEncrypt(const char* keyfile)
secret_len = htonl(secret_len); secret_len = htonl(secret_len);
if ( ! (fwrite("BROENC1", 7, 1, f) && if ( fwrite("BROENC1", 7, 1, f) < 1 ||
fwrite(&secret_len, sizeof(secret_len), 1, f) && fwrite(&secret_len, sizeof(secret_len), 1, f) < 1 ||
fwrite(secret, ntohl(secret_len), 1, f) && fwrite(secret, ntohl(secret_len), 1, f) < 1 ||
fwrite(iv, iv_len, 1, f)) ) fwrite(iv, iv_len, 1, f) < 1 )
{ {
reporter->Error("can't write header to log file %s: %s", reporter->Error("can't write header to log file %s: %s",
name, strerror(errno)); name, strerror(errno));
@ -736,7 +736,7 @@ void BroFile::FinishEncrypt()
int outl; int outl;
EVP_SealFinal(cipher_ctx, cipher_buffer, &outl); EVP_SealFinal(cipher_ctx, cipher_buffer, &outl);
if ( outl && ! fwrite(cipher_buffer, outl, 1, f) ) if ( outl && fwrite(cipher_buffer, outl, 1, f) < 1 )
{ {
reporter->Error("write error for %s: %s", reporter->Error("write error for %s: %s",
name, strerror(errno)); name, strerror(errno));
@ -777,7 +777,7 @@ int BroFile::Write(const char* data, int len)
return 0; return 0;
} }
if ( outl && ! fwrite(cipher_buffer, outl, 1, f) ) if ( outl && fwrite(cipher_buffer, outl, 1, f) < 1 )
{ {
reporter->Error("write error for %s: %s", reporter->Error("write error for %s: %s",
name, strerror(errno)); name, strerror(errno));
@ -792,8 +792,7 @@ int BroFile::Write(const char* data, int len)
return 1; return 1;
} }
len = fwrite(data, 1, len, f); if ( fwrite(data, len, 1, f) < 1 )
if ( len <= 0 )
return false; return false;
if ( rotate_size && current_size < rotate_size && current_size + len >= rotate_size ) if ( rotate_size && current_size < rotate_size && current_size + len >= rotate_size )

View file

@ -22,7 +22,7 @@ static void bad_pipe_op(const char* which)
void Flare::Fire() void Flare::Fire()
{ {
char tmp; char tmp = 0;
for ( ; ; ) for ( ; ; )
{ {

View file

@ -110,7 +110,7 @@ public:
T result = 0; T result = 0;
// loop optmized with Duff's Device // loop optmized with Duff's Device
register unsigned n = (size + 7) / 8; unsigned n = (size + 7) / 8;
switch ( size % 8 ) { switch ( size % 8 ) {
case 0: do { result ^= byte_lookup[offset++][*p++]; case 0: do { result ^= byte_lookup[offset++][*p++];
case 7: result ^= byte_lookup[offset++][*p++]; case 7: result ^= byte_lookup[offset++][*p++];

View file

@ -4190,7 +4190,7 @@ bool SocketComm::Listen()
setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0 ) setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0 )
Error(fmt("can't set IPV6_V6ONLY, %s", strerror(errno))); Error(fmt("can't set IPV6_V6ONLY, %s", strerror(errno)));
if ( bind(fd, res->ai_addr, res->ai_addrlen) < 0 ) if ( ::bind(fd, res->ai_addr, res->ai_addrlen) < 0 )
{ {
Error(fmt("can't bind to %s:%s, %s", l_addr_str.c_str(), Error(fmt("can't bind to %s:%s, %s", l_addr_str.c_str(),
port_str, strerror(errno))); port_str, strerror(errno)));

View file

@ -131,18 +131,19 @@ Trigger::Trigger(Expr* arg_cond, Stmt* arg_body, Stmt* arg_timeout_stmts,
arg_frame->SetDelayed(); arg_frame->SetDelayed();
} }
Val* timeout = arg_timeout ? arg_timeout->ExprVal() : 0; Val* timeout_val = arg_timeout ? arg_timeout->Eval(arg_frame) : 0;
// Make sure we don't get deleted if somebody calls a method like // Make sure we don't get deleted if somebody calls a method like
// Timeout() while evaluating the trigger. // Timeout() while evaluating the trigger.
Ref(this); Ref(this);
if ( ! Eval() && timeout ) if ( ! Eval() && timeout_val )
{ {
timer = new TriggerTimer(timeout->AsInterval(), this); timer = new TriggerTimer(timeout_val->AsInterval(), this);
timer_mgr->Add(timer); timer_mgr->Add(timer);
} }
Unref(timeout_val);
Unref(this); Unref(this);
} }

View file

@ -21,7 +21,9 @@ static const char* smtp_cmd_word[] = {
#include "SMTP_cmd.def" #include "SMTP_cmd.def"
}; };
#define SMTP_CMD_WORD(code) ((code >= 0) ? smtp_cmd_word[code] : "(UNKNOWN)") static const char* unknown_cmd = "(UNKNOWN)";
#define SMTP_CMD_WORD(code) ((code >= 0) ? smtp_cmd_word[code] : unknown_cmd)
SMTP_Analyzer::SMTP_Analyzer(Connection* conn) SMTP_Analyzer::SMTP_Analyzer(Connection* conn)
@ -422,7 +424,6 @@ void SMTP_Analyzer::NewReply(const int reply_code)
if ( state == SMTP_AFTER_GAP && reply_code > 0 ) if ( state == SMTP_AFTER_GAP && reply_code > 0 )
{ {
state = SMTP_GAP_RECOVERY; state = SMTP_GAP_RECOVERY;
const char* unknown_cmd = SMTP_CMD_WORD(-1);
RequestEvent(strlen(unknown_cmd), unknown_cmd, 0, ""); RequestEvent(strlen(unknown_cmd), unknown_cmd, 0, "");
/* /*
if ( line_after_gap ) if ( line_after_gap )

View file

@ -357,7 +357,7 @@ cq_remove(register struct cq_handle *hp, register double pri,
/* The priority must be positive and the cookie non-null */ /* The priority must be positive and the cookie non-null */
if (pri <= 0.0 || cookie == NULL) if (pri <= 0.0 || cookie == NULL)
return (-0); return (0);
bp = hp->buckets + PRI2BUCKET(hp, pri); bp = hp->buckets + PRI2BUCKET(hp, pri);
if (! BUCKETINUSE(bp)) if (! BUCKETINUSE(bp))
@ -370,7 +370,7 @@ cq_remove(register struct cq_handle *hp, register double pri,
} }
if ( ! bp ) if ( ! bp )
return (-0); return (0);
/* Unlink entry */ /* Unlink entry */
if ( ! bp2 ) { if ( ! bp2 ) {

View file

@ -506,6 +506,7 @@ bool PktSrc::ApplyBPFFilter(int index, const struct pcap_pkthdr *hdr, const u_ch
{ {
Error(fmt("BPF filter %d not compiled", index)); Error(fmt("BPF filter %d not compiled", index));
Close(); Close();
return false;
} }
if ( code->MatchesAnything() ) if ( code->MatchesAnything() )

View file

@ -266,7 +266,11 @@ protected:
Properties() Properties()
{ {
selectable_fd = -1;
link_type = -1;
hdr_size = -1;
netmask = PCAP_NETMASK_UNKNOWN; netmask = PCAP_NETMASK_UNKNOWN;
is_live = false;
} }
}; };

View file

@ -21,6 +21,9 @@ PcapSource::PcapSource(const std::string& path, bool is_live)
{ {
props.path = path; props.path = path;
props.is_live = is_live; props.is_live = is_live;
pd = 0;
memset(&current_hdr, 0, sizeof(current_hdr));
memset(&last_hdr, 0, sizeof(last_hdr));
last_data = 0; last_data = 0;
} }

View file

@ -8,13 +8,25 @@
event bro_init() event bro_init()
{ {
local h1: addr = 127.0.0.1; local h: addr = 127.0.0.1;
when ( local h1name = lookup_addr(h1) ) when ( local hname = lookup_addr(h) )
{ {
print "lookup successful"; print "lookup successful";
terminate(); terminate();
} }
timeout 10sec
{
print "timeout (1)";
}
local to = 5sec;
# Just checking that timeouts can use arbitrary expressions...
when ( local hname2 = lookup_addr(h) ) {}
timeout to {}
when ( local hname3 = lookup_addr(h) ) {}
timeout to + 2sec {}
print "done"; print "done";
} }