mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
bifs/to_port: Avoid ASAN errors when calling to_port("")
Ran into this when using to_port(getenv(...)) for an undefined/empty environment variable. ASAN doesn't like that the slash variable ends up being access behind the string.
This commit is contained in:
parent
686eb54f95
commit
c89be2a13b
3 changed files with 7 additions and 1 deletions
|
@ -2877,7 +2877,7 @@ function raw_bytes_to_v6_addr%(x: string%): addr
|
|||
function to_port%(s: string%): port
|
||||
%{
|
||||
int port = 0;
|
||||
if ( s->Len() < 10 )
|
||||
if ( s->Len() > 0 && s->Len() < 10 )
|
||||
{
|
||||
char* slash;
|
||||
errno = 0;
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
0/udp
|
||||
0/icmp
|
||||
0/unknown
|
||||
0/unknown
|
||||
123/unknown
|
||||
123/unknown
|
||||
256/tcp
|
||||
256/udp
|
||||
256/icmp
|
||||
|
|
|
@ -11,6 +11,9 @@ event zeek_init()
|
|||
print to_port("0/udp");
|
||||
print to_port("0/icmp");
|
||||
print to_port("not a port");
|
||||
print to_port("");
|
||||
print to_port("123");
|
||||
print to_port("123/");
|
||||
|
||||
local a: transport_proto = tcp;
|
||||
local b: transport_proto = udp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue