diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2015-09-15 19:33:32 +0200 |
---|---|---|
committer | Martin Kaiser <wireshark@kaiser.cx> | 2015-09-17 07:39:23 +0000 |
commit | 5fa0bb2d0262d25526b67219a546b2844172769f (patch) | |
tree | 3c1bfd35fefb53ca56b1aec1f2176884b00415df /epan/ftypes/ftype-bytes.c | |
parent | fade468864de78a76f584cc62edeab8e55bd7973 (diff) | |
download | wireshark-5fa0bb2d0262d25526b67219a546b2844172769f.tar.gz |
change the representation of an empty byte array in a display filter
by default, an empty byte array (FT_BYTES) is represented as an empty string
thus, using "Apply as Filter / Selected" on such an item creates an
invalid display filter expression, e.g. dvb-ci.mmi.char_tbl==
represent an empty byte array as "" if we're compiling a display filter
expression
Bug: 11526
Change-Id: Ie94507a24a496e0c25bcdadfab72fdf9fb35958a
Reviewed-on: https://code.wireshark.org/review/10540
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Diffstat (limited to 'epan/ftypes/ftype-bytes.c')
-rw-r--r-- | epan/ftypes/ftype-bytes.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c index 2bacdfd8b9..008772b7cf 100644 --- a/epan/ftypes/ftype-bytes.c +++ b/epan/ftypes/ftype-bytes.c @@ -56,12 +56,12 @@ bytes_fvalue_set(fvalue_t *fv, GByteArray *value) } static int -bytes_repr_len(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_) +bytes_repr_len(fvalue_t *fv, ftrepr_t rtype, int field_display _U_) { if (fv->value.bytes->len == 0) { - /* Empty array of bytes, so the representation - * is an empty string. */ - return 0; + /* An empty array of bytes is represented as "" in a + display filter and as an empty string otherwise. */ + return (rtype == FTREPR_DFILTER) ? 2 : 0; } else { /* 3 bytes for each byte of the byte "NN<separator character>" minus 1 byte * as there's no trailing "<separator character>". */ @@ -138,7 +138,7 @@ system_id_to_repr(fvalue_t *fv, ftrepr_t rtype, int field_display, char *buf) } static void -bytes_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display, char *buf) +bytes_to_repr(fvalue_t *fv, ftrepr_t rtype, int field_display, char *buf) { char separator; @@ -158,8 +158,16 @@ bytes_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display, char *buf) break; } - if (fv->value.bytes->len) + if (fv->value.bytes->len) { buf = bytes_to_hexstr_punct(buf, fv->value.bytes->data, fv->value.bytes->len, separator); + } + else { + if (rtype == FTREPR_DFILTER) { + /* An empty byte array in a display filter is represented as "" */ + *buf++ = '"'; + *buf++ = '"'; + } + } *buf = '\0'; } |