diff --git a/CHANGES b/CHANGES index 93e5c90536..a9fd9edafb 100644 --- a/CHANGES +++ b/CHANGES @@ -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 * Make const variables actually constant. Both local and global diff --git a/VERSION b/VERSION index b02f44968d..57099cc521 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1-231 +2.1-234 diff --git a/src/Func.cc b/src/Func.cc index cf548b2d95..9b94b15d97 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -282,13 +282,14 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const #ifdef PROFILE_BRO_FUNCTIONS DEBUG_MSG("Function: %s\n", id->Name()); #endif - if ( ! bodies.size() ) + if ( ! bodies.size() ) { // Can only happen for events and hooks. assert(Flavor() == FUNC_FLAVOR_EVENT || Flavor() == FUNC_FLAVOR_HOOK); loop_over_list(*args, i) Unref((*args)[i]); - return 0 ; + + return Flavor() == FUNC_FLAVOR_HOOK ? new Val(true, TYPE_BOOL) : 0; } SegmentProfiler(segment_logger, location); diff --git a/src/bro.bif b/src/bro.bif index d945e54ef4..bebcde18c3 100644 --- a/src/bro.bif +++ b/src/bro.bif @@ -2684,8 +2684,9 @@ function to_port%(s: string%): port if ( s->Len() < 10 ) { char* slash; + errno = 0; port = strtol(s->CheckString(), &slash, 10); - if ( port ) + if ( ! errno ) { ++slash; if ( streq(slash, "tcp") ) diff --git a/testing/btest/Baseline/bifs.to_port/out b/testing/btest/Baseline/bifs.to_port/out index 79796d605e..7744914c30 100644 --- a/testing/btest/Baseline/bifs.to_port/out +++ b/testing/btest/Baseline/bifs.to_port/out @@ -1,6 +1,9 @@ 123/tcp 123/udp 123/icmp +0/tcp +0/udp +0/icmp 0/unknown 256/tcp 256/udp diff --git a/testing/btest/Baseline/language.hook/out b/testing/btest/Baseline/language.hook/out index bef25193b8..d4f367f875 100644 --- a/testing/btest/Baseline/language.hook/out +++ b/testing/btest/Baseline/language.hook/out @@ -3,6 +3,7 @@ myhook return F myhook return T myhook, &priority=5, [a=37, b=goobye world] F +T myhook3, 8 T myhook4, 2 diff --git a/testing/btest/bifs/to_port.bro b/testing/btest/bifs/to_port.bro index 0dfecac43e..b2289b8a21 100644 --- a/testing/btest/bifs/to_port.bro +++ b/testing/btest/bifs/to_port.bro @@ -7,6 +7,9 @@ event bro_init() print to_port("123/tcp"); print to_port("123/udp"); 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"); local a: transport_proto = tcp;