Merge remote-tracking branch 'origin/fastpath'

* origin/fastpath:
  Fix return value of hook calls that have no handlers.
  Fix to_port() BIF for port strings with a port number of zero.
This commit is contained in:
Robin Sommer 2012-12-20 12:12:19 -08:00
commit 40007d075c
7 changed files with 21 additions and 4 deletions

View file

@ -1,4 +1,12 @@
2.1-234 | 2012-12-20 12:12:19 -0800
* Fix return value of hook calls that have no handlers. For this
case, the return value is always true. (Jon Siwek)
* Fix to_port() BIF for port strings with a port number of zero.
(Jon Siwek)
2.1-231 | 2012-12-14 14:51:35 -0800 2.1-231 | 2012-12-14 14:51:35 -0800
* Make const variables actually constant. Both local and global * Make const variables actually constant. Both local and global

View file

@ -1 +1 @@
2.1-231 2.1-234

View file

@ -282,13 +282,14 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
#ifdef PROFILE_BRO_FUNCTIONS #ifdef PROFILE_BRO_FUNCTIONS
DEBUG_MSG("Function: %s\n", id->Name()); DEBUG_MSG("Function: %s\n", id->Name());
#endif #endif
if ( ! bodies.size() ) if ( ! bodies.size() )
{ {
// Can only happen for events and hooks. // Can only happen for events and hooks.
assert(Flavor() == FUNC_FLAVOR_EVENT || Flavor() == FUNC_FLAVOR_HOOK); assert(Flavor() == FUNC_FLAVOR_EVENT || Flavor() == FUNC_FLAVOR_HOOK);
loop_over_list(*args, i) loop_over_list(*args, i)
Unref((*args)[i]); Unref((*args)[i]);
return 0 ;
return Flavor() == FUNC_FLAVOR_HOOK ? new Val(true, TYPE_BOOL) : 0;
} }
SegmentProfiler(segment_logger, location); SegmentProfiler(segment_logger, location);

View file

@ -2684,8 +2684,9 @@ function to_port%(s: string%): port
if ( s->Len() < 10 ) if ( s->Len() < 10 )
{ {
char* slash; char* slash;
errno = 0;
port = strtol(s->CheckString(), &slash, 10); port = strtol(s->CheckString(), &slash, 10);
if ( port ) if ( ! errno )
{ {
++slash; ++slash;
if ( streq(slash, "tcp") ) if ( streq(slash, "tcp") )

View file

@ -1,6 +1,9 @@
123/tcp 123/tcp
123/udp 123/udp
123/icmp 123/icmp
0/tcp
0/udp
0/icmp
0/unknown 0/unknown
256/tcp 256/tcp
256/udp 256/udp

View file

@ -3,6 +3,7 @@ myhook return F
myhook return T myhook return T
myhook, &priority=5, [a=37, b=goobye world] myhook, &priority=5, [a=37, b=goobye world]
F F
T
myhook3, 8 myhook3, 8
T T
myhook4, 2 myhook4, 2

View file

@ -7,6 +7,9 @@ event bro_init()
print to_port("123/tcp"); print to_port("123/tcp");
print to_port("123/udp"); print to_port("123/udp");
print to_port("123/icmp"); print to_port("123/icmp");
print to_port("0/tcp");
print to_port("0/udp");
print to_port("0/icmp");
print to_port("not a port"); print to_port("not a port");
local a: transport_proto = tcp; local a: transport_proto = tcp;