Skip to content

Commit

Permalink
Fixed two bugs in display filter parsing.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gilramir committed Aug 12, 1999
1 parent 2fd7555 commit 336b94f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
16 changes: 8 additions & 8 deletions dfilter-grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand Down
22 changes: 17 additions & 5 deletions dfilter-scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions dfilter.c
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 336b94f

Please sign in to comment.