Add type checking to string_cat arguments

This commit is contained in:
Tim Wojtulewicz 2022-08-26 15:30:11 -07:00
parent 686eb54f95
commit ed4521af60
6 changed files with 37 additions and 0 deletions

View file

@ -64,7 +64,15 @@ function string_cat%(...%): string
%{
int n = 0;
for ( const auto& a : @ARG@ )
{
if ( a->GetType()->Tag() != TYPE_STRING )
{
zeek::reporter->Error("string_cat() requires string arguments");
return val_mgr->EmptyString();
}
n += a->AsString()->Len();
}
u_char* b = new u_char[n+1];
zeek::String* s = new zeek::String(1, b, n);