[Bro] Inaccurate line number in error message
Vern Paxson
vern at icir.org
Mon Jun 20 00:29:46 PDT 2005
> when running the following policy snippet below, one gets the error
> message "line 1 (i): error, not a BRO type".
>
> 1 function foo(i: int)
> 2 {
> 3 # ...
> 4 local j: i;
> 5 }
>
> However, there is no error in line 1. It's in line 4, which should be "j
> = i" instead. I just had a more complicated scenario with basically this
> error and it took me ages to locate the problem. I kept looking in the
> wrong spot because my line "4" was much further down in a biggish
> function.
>
> After looking at parse.y for a while I conclude that I don't really know
> the right way to fix this -- could anyone provide pointers, or better
> yet, a patch? Thanks!
The following does the trick.
Vern
Index: parse.in
===================================================================
RCS file: /home/portnoy/u2/src/projects/bro/src/parse.in,v
retrieving revision 1.6
diff -u -r1.6 parse.in
--- parse.in 23 Jan 2005 21:45:42 -0000 1.6
+++ parse.in 20 Jun 2005 07:27:45 -0000
@@ -694,8 +694,9 @@
{
if ( ! $1 || ! ($$ = $1->AsType()) )
{
+ NullStmt here;
if ( $1 )
- $1->Error("not a BRO type");
+ $1->Error("not a BRO type", &here);
$$ = error_type();
}
else
More information about the Bro
mailing list