diff options
author | João Valverde <j@v6e.pt> | 2021-10-06 18:24:40 +0100 |
---|---|---|
committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-10-07 23:01:50 +0000 |
commit | 5fcdf256973cd77447ca1ab4a56843ad65f27705 (patch) | |
tree | 5cb6965d702b3c11f2752b0a0f052038fb6b1845 /epan/ftypes/ftype-bytes.c | |
parent | d8b28f8040d30d52b19819cff3b686a87eb61381 (diff) |
dfilter: Generalize special case of one byte literal
Instead of only accepting a byte literal specification if the LHS is a
len-1 byte string, accept it everywhere bytes are wanted.
Before:
$ dftest "frame[1] contains 0x01"
Filter: frame[1] contains 0x01
Constants:
00000 PUT_FVALUE 01 <FT_BYTES> -> reg#2
Instructions:
(...)
$ dftest "frame[1:4] contains 0x01"
Filter: frame[1:4] contains 0x01
dftest: "0x01" is not a valid byte string.
After:
$ dftest "frame[1:4] contains 0x01"
$ Filter: frame[1:4] contains 0x01
Constants:
00000 PUT_FVALUE 01 <FT_BYTES> -> reg#2
Instructions:
(...)
Diffstat (limited to 'epan/ftypes/ftype-bytes.c')
-rw-r--r-- | epan/ftypes/ftype-bytes.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c index fececd36bd..7072bbaf23 100644 --- a/epan/ftypes/ftype-bytes.c +++ b/epan/ftypes/ftype-bytes.c @@ -239,6 +239,15 @@ bytes_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U GByteArray *bytes; gboolean res; + /* + * Special case where the byte string is specified using a one byte + * hex literal. We can't allow this for byte strings that are longer + * than one byte, because then we'd have to know which endianness the + * byte string should be in. + */ + if (strlen(s) == 4 && s[0] == '0' && s[1] == 'x') + s = s + 2; + bytes = g_byte_array_new(); res = hex_str_to_bytes(s, bytes, TRUE); |