aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>1999-08-12 15:10:48 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>1999-08-12 15:10:48 +0000
commit336b94f50691d1bb759605a545f6b3bda69b3203 (patch)
treec98df9500f1a195d50eb16c18ab75c4ee25d7c60
parent2fd75551101a2f729f285efe33d850421bd5da47 (diff)
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
-rw-r--r--NEWS1
-rw-r--r--dfilter-grammar.y16
-rw-r--r--dfilter-scanner.l22
-rw-r--r--dfilter.c6
4 files changed, 29 insertions, 16 deletions
diff --git a/NEWS b/NEWS
index dd97dea65b..4d673d984e 100644
--- a/NEWS
+++ b/NEWS
@@ -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)
diff --git a/dfilter-grammar.y b/dfilter-grammar.y
index 998f2a6e7a..dbdfa5d598 100644
--- a/dfilter-grammar.y
+++ b/dfilter-grammar.y
@@ -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);
}
diff --git a/dfilter-scanner.l b/dfilter-scanner.l
index 6a679b63ca..d10e69ec6b 100644
--- a/dfilter-scanner.l
+++ b/dfilter-scanner.l
@@ -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;
diff --git a/dfilter.c b/dfilter.c
index 41587df426..4e53b8f6e3 100644
--- a/dfilter.c
+++ b/dfilter.c
@@ -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