Fixed two bugs in display filter parsing.

1. Some IP addresses (like 0.0.0.0) would be interpreted as byte ranges.
2. Parens were being ignored.

Thanks to Guy for pointing these out to me.

svn path=/trunk/; revision=477
This commit is contained in:
Gilbert Ramirez 1999-08-12 15:10:48 +00:00
parent 2fd7555110
commit 336b94f506
4 changed files with 29 additions and 16 deletions

1
NEWS
View File

@ -1,5 +1,6 @@
Overview of changes in Ethereal 0.7.3:
* Fixed bug in RSVP, added RSVP+ support (Ashok)
* Fixed bug in display filter parsing (Gilbert)
Overview of changes in Ethereal 0.7.2:
* Another memory leak fix (Jochen)

View File

@ -3,7 +3,7 @@
/* dfilter-grammar.y
* Parser for display filters
*
* $Id: dfilter-grammar.y,v 1.6 1999/08/11 16:25:07 gram Exp $
* $Id: dfilter-grammar.y,v 1.7 1999/08/12 15:10:48 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -94,6 +94,9 @@ GNode *dfilter_tree = NULL;
* faster than the tree when we go back and free the byte arrays */
GSList *dfilter_list_byte_arrays = NULL;
/* In dfilter-scanner.l */
GByteArray* byte_str_to_guint8_array(const char *s);
%}
%union {
@ -257,14 +260,11 @@ bytes_value: T_VAL_BYTES
}
| T_VAL_UNQUOTED_STRING
{ /* one byte */
GByteArray *barray = g_byte_array_new();
guint8 val;
char *endptr;
{ /* one or 4 bytes */
GByteArray *barray;
dfilter_list_byte_arrays = g_slist_append(dfilter_list_byte_arrays, barray);
val = (guint8) strtoul($1, &endptr, 16);
g_byte_array_append(barray, &val, 1);
/* the next function appends to dfilter_list_byte_arrays for me */
barray = byte_str_to_guint8_array($1);
$$ = dfilter_mknode_bytes_value(barray);
g_free($1);
}

View File

@ -3,7 +3,7 @@
/* dfilter-scanner.l
* Scanner for display filters
*
* $Id: dfilter-scanner.l,v 1.3 1999/08/05 16:42:31 gram Exp $
* $Id: dfilter-scanner.l,v 1.4 1999/08/12 15:10:48 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -56,7 +56,6 @@
#include "dfilter-grammar.h"
static int ether_str_to_guint8_array(const char *s, guint8 *mac);
static GByteArray* byte_str_to_guint8_array(const char *s);
/* in dfilter-grammar.y */
extern GSList *dfilter_list_byte_arrays;
@ -140,13 +139,25 @@ false { yylval.operand = TOK_FALSE; return TOK_FALSE; }
}
({hex}{hexsep}){1,4}{hex} { /* small byte array */
({hex}{hexsep}){1,2}{hex} { /* small byte array */
yylval.bytes = byte_str_to_guint8_array(yytext);
return T_VAL_BYTES;
}
({hex}{hexsep}){5}{hex} { /* Ether Hardware Address */
({hex}{hexsep}){3}{hex} { /* possibly IPv4 address (e.g., 0.0.0.0) */
yylval.id = g_strdup(yytext);
return T_VAL_UNQUOTED_STRING;
}
({hex}{hexsep}){4}{hex} { /* small byte array */
yylval.bytes = byte_str_to_guint8_array(yytext);
return T_VAL_BYTES;
}
({hex}{hexsep}){5}{hex} { /* possibly Ether Hardware Address */
/* it's faster to copy six bytes to yylval than to create a GByteArray
* structure and append 6 bytes. That means I'll have to handle this
@ -232,6 +243,7 @@ false { yylval.operand = TOK_FALSE; return TOK_FALSE; }
return T_VAL_UNQUOTED_STRING;
}
. return yytext[0];
%%
/* Resets scanner and assigns the char* argument
@ -307,7 +319,7 @@ ether_str_to_guint8_array(const char *s, guint8 *mac)
*
* Returns a non-null GByteArray pointer on success, NULL on failure.
*/
static GByteArray*
GByteArray*
byte_str_to_guint8_array(const char *s)
{
GByteArray *barray;

View File

@ -1,7 +1,7 @@
/* dfilter.c
* Routines for display filters
*
* $Id: dfilter.c,v 1.6 1999/08/03 15:04:25 gram Exp $
* $Id: dfilter.c,v 1.7 1999/08/12 15:10:48 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -151,8 +151,8 @@ static void
clear_byte_array(gpointer data, gpointer user_data)
{
GByteArray *barray = data;
g_byte_array_free(barray, TRUE);
if (barray)
g_byte_array_free(barray, TRUE);
}
void