[Bro] script question

Dk Jack dnj0496 at gmail.com
Tue Nov 8 13:52:29 PST 2016

Found an interesting quirk of bro scripting. Not sure if its a quirk or a

function myfunction()
    if (T) {
        local var = "Hello, World!";
        print var;
    } else {
        local var = "Goodbye, World!";
        print var;

For this code, I get the error:

error in ././trybro.bro, line 6 and ././trybro.bro, line 9: already
defined (var)

If I make the local variable names different i.e. var and var2, it
doesn't complain. I think this is a bug. Let me know...


PS: Since I couldn't find an ends_with function, I wrote one. Let me
know if this is ok...

function ends_with(input_string: string, match_pattern: string) : bool
  local offset = |input_string| - |match_pattern| + 1;
  local sstring = sub_bytes(input_string, offset, |match_pattern|);

  if (sstring == match_pattern)
    return T;
    return F;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ICSI.Berkeley.EDU/pipermail/bro/attachments/20161108/4268a679/attachment.html 

More information about the Bro mailing list