Commit Graph

100 Commits

Author SHA1 Message Date
Guy Harris 272502790b Add FT_STRINGZTRUNC.
FT_STRINGZPAD is for null-*padded* strings, where the field is in an
area of specified length, and, if the string is shorter than that
length, all bytes past the end of the string are NULs.

FT_STRINGZTRUNC is for null-*truncated* strings, where the field is in
an area of specified length and, if the string is shorter than that
length, there's a null character (which might be more than one byte, for
UCS-2, UTF-16, or UTF-32), and anything after that is not guaranteed to
have any particular value.

Use IS_FT_STRING() in some places rather than enumerating all the string
types, so that those places get automatically changed if the set of
string types changes.
2020-09-12 14:16:12 -07:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c
Reviewed-on: https://code.wireshark.org/review/34089
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26 18:44:40 +00:00
Guy Harris 333e915cff Better name for the routine.
It doesn't necessarily produce an FT_BYTES value any more.

Change-Id: I7bad1e328394a829400bd139c48a9538c4892818
Reviewed-on: https://code.wireshark.org/review/28318
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-06-18 00:30:37 +00:00
Guy Harris 078a53f994 For the contains operator, both sides have to have the same type.
Have charconst_to_bytes() take the desired type as an argument, and pass
it to dfilter_fvalue_from_unparsed().

Bug: 14084
Change-Id: I11db417311b9681b18c4a3fca2862b35837194d7
Reviewed-on: https://code.wireshark.org/review/28315
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-06-17 22:02:47 +00:00
Peter Wu 1ff82572ca dfilter: add range support to set membership operator ("f in {x .. y}")
Allow "tcp.srcport in {1662 1663 1664}" to be abbreviated to
"tcp.srcport in {1662 .. 1664}". The range operator is supported for any
field value which supports the "<=" and "=>" operators and thus works
for integers, IP addresses, etc.

The naive mapping "tcp.srcport >= 1662 and tcp.srcport <= 1664" is not
used because it does not have the intended effect with fields that have
multiple occurrences (e.g. tcp.port). Each condition could be satisfied
by an other value. Therefore a new DVFM instruction (ANY_IN_RANGE) is
added to test the range condition against each individual field value.

Bug: 14180
Change-Id: I53c2d0f9bc9d4f0ffaabde9a83442122965c95f7
Reviewed-on: https://code.wireshark.org/review/26945
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-04-18 03:47:02 +00:00
Dario Lombardo 55c68ee69c epan: use SPDX indentifiers.
Skipping dissectors dir for now.

Change-Id: I717b66bfbc7cc81b83f8c2cbc011fcad643796aa
Reviewed-on: https://code.wireshark.org/review/25694
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 19:29:45 +00:00
Peter Wu 2f35a811a3 dfilter: fix memleak when using value_string values
When using a filter such as "ncp.alloc_reply_lvl2 == FALSE", a memory
leak would occur as follows:

 1. dfilter_fvalue_from_unparsed is called and
 2. ends up calling _uint64_from_unparsed
 3. which fails with error message "\"FALSE\" is not a valid number.".
 4. Next, mk_fvalue_from_val_string is called which maps "FALSE" to 0
 5. and the filter is successfully compiled.
 6. dfwork_free deliberately does not free the error message (since
    there should be none at this point) and we have a memleak (from 3).

Fix this memleak by clearing the error message when a successful
value_string mapping is found.

Change-Id: I78d59a4336342b09dc5448ea994b2e1d199d7f3f
Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1302
Reviewed-on: https://code.wireshark.org/review/21497
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2017-05-04 18:56:10 +00:00
Alexis La Goutte 26950539d6 semcheck: Fix Dead Store (Dead assignement/Dead increment) Warning found by Clang
Change-Id: I000f9df1e41cab7fa0132153ff95caf31f3f6a6a
Reviewed-on: https://code.wireshark.org/review/17892
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-25 03:20:08 +00:00
Guy Harris c786aa56ad Fix a copy-and-pasteo.
Fix the handling of the case of a "matches" operator with a field and a
character constant as operands.

Change-Id: I6451cee907d8486db96937173d0098de91ce7956
Reviewed-on: https://code.wireshark.org/review/18424
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-24 08:17:09 +00:00
Guy Harris d7fe514fc0 Improve support for single-character fields and filter expressions.
Add an FT_CHAR type, which is like FT_UINT8 except that the value is
displayed as a C-style character constant.

Allow use of C-style character constants in filter expressions; they can
be used in comparisons with all integral types, and in "contains"
operators.

Use that type for some fields that appear (based on the way they're
displayed, or on the use of C-style character constants in their
value_string tables) to be 1-byte characters rather than 8-bit numbers.

Change-Id: I39a9f0dda0bd7f4fa02a9ca8373216206f4d7135
Reviewed-on: https://code.wireshark.org/review/17787
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-19 02:51:13 +00:00
Michael Mann 1da1f945e2 Fix checkAPI.pl warnings about printf
Many of the complaints from checkAPI.pl for use of printf are when its embedded
in an #ifdef and checkAPI isn't smart enough to figure that out.
The other (non-ifdef) use is dumping internal structures (which is a type of
debug functionality)
Add a "ws_debug_printf" macro for printf to pacify the warnings.

Change-Id: I63610e1adbbaf2feffb4ec9d4f817247d833f7fd
Reviewed-on: https://code.wireshark.org/review/16623
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-07-25 04:26:50 +00:00
Guy Harris 3570d264c1 FT_BOOLEAN is now stored as a 64-bit value; treat it as such.
Always look and set the uinteger64 member of the union for FT_BOOLEAN
values.

Bug: 12236
Change-Id: I7b0166e564b9d6cbb80051a81714a4b4c5f740a2
Reviewed-on: https://code.wireshark.org/review/14481
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-03-15 21:21:00 +00:00
João Valverde 7f520c352d Fix two warnings for semcheck.c
semcheck.c:986:24: warning: cast from function call of type 'sttype_id_t' to non-matching type 'int' [-Wbad-function-cast]
semcheck.c:986:5: warning: format '%p' expects argument of type 'void *', but argument 3 has type 'struct stnode_t *' [-Wformat=]

Change-Id: I83031251c83f6597eb7c31f35e02c5a95bd2dabb
Reviewed-on: https://code.wireshark.org/review/13930
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-02-14 22:10:22 +00:00
Michal Labedzki 22d561c436 Add support for IEEE-11073 FLOATs
Add support for IEEE-11073 32-bit FLOAT and 16 bit SFLOAT field types.
Use them in Bluetooth ATT dissector.

Change-Id: Ife0f3843da84a9af23483b0a0d9b69cd2f511d08
Reviewed-on: https://code.wireshark.org/review/12680
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Michal Labedzki <michal.labedzki@tieto.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2015-12-29 14:20:02 +00:00
Jeffrey Smith 80322d88da dfilter: Add membership operator
Added a new relational test: 'x in {a b c}'.  The only LHS entity
supported at this time is a field.  The generated DFVM operations are
equivalent to an OR'ed series of =='s, but with the redundant existence
tests removed.

Change-Id: Iddc89b81cf7ad6319aef1a2a94f93314cb721a8a
Reviewed-on: https://code.wireshark.org/review/10246
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-09-11 06:31:33 +00:00
Pascal Quantin 523ce152e8 Do not try to display a value_string for FT_FRAMENUM type
The hfinfo->strings pointer is used to store a ft_framenum_type_t

Bug: 11325
Change-Id: Ia6ee1bdd4f1e6ff93907e6107fcecab56c0320de
Reviewed-on: https://code.wireshark.org/review/9458
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-07-02 11:36:11 +00:00
JC Wren e2bcee6ac4 Make FT_{U}INT64 behave more like FT_{U}INT32, add support for FT_{U}INT{40,48,56}
Change-Id: I57354c309ecf3a0c8f0c7cff485638027f30bb19
Reviewed-on: https://code.wireshark.org/review/5813
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-02-21 16:57:52 +00:00
Bill Meier 3e3fc9fc5e epan/dfilter/*.c: As needed: Add editor modelines & Fix indentation
Change-Id: I410839329a98bd806c60961dfb9693d5eeeeb702
Reviewed-on: https://code.wireshark.org/review/7104
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2015-02-13 19:04:44 +00:00
Guy Harris cfcbb28671 Clean up ftype-conversion and dfilter error message string handling.
Have dfilter_compile() take an additional gchar ** argument, pointing to
a gchar * item that, on error, gets set to point to a g_malloc()ed error
string.  That removes one bit of global state from the display filter
parser, and doesn't impose a fixed limit on the error message strings.

Have fvalue_from_string() and fvalue_from_unparsed() take a gchar **
argument, pointer to a gchar * item, rather than an error-reporting
function, and set the gchar * item to point to a g_malloc()ed error
string on an error.

Allow either gchar ** argument to be null; if the argument is null, no
error message is allocated or provided.

Change-Id: Ibd36b8aaa9bf4234aa6efa1e7fb95f7037493b4c
Reviewed-on: https://code.wireshark.org/review/6608
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-01-18 10:22:59 +00:00
Michael Mann 71c02b20eb Create FT_FCWWN field type.
Also, convert the "string" hf_ entries that used tvb_fcwwn_to_str as a string to use proto_tree_add_item with FT_FCWWN type.

Change-Id: I4ca77870499fd8239584a70874998b5d194a7167
Reviewed-on: https://code.wireshark.org/review/6036
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-12-28 20:05:29 +00:00
Michal Labedzki ee4a7f2c5d DisplayFilter: Check also another fields with the same name
This adds possibility to have two fields with the same abbrev name
but different type, for example FT_ETHER and FT_STRING.
That allows to compare each one to find a valid field.

Change-Id: I8b2a1708ac9648b7a4289777c72a0f3b18f3d8f8
Reviewed-on: https://code.wireshark.org/review/5702
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
2014-12-18 11:02:37 +00:00
Peter Wu f2b4daf400 Add printf-format annotations, fix garbage
The WRETH dissector showed up some garbage in the column display. Upon
further inspection, it turns out that the format string had a trailing
percent sign which caused (unsigned)-1 to be returned by
g_printf_string_upper_bound (in emem_strdup_vprintf). Then ep_alloc is
called with (unsigned)-1 + 1 = 0 memory, no wonder that garbage shows
up. ASAN could not even catch this error because EP is in charge of
this.

So, start adding G_GNUC_PRINTF annotations in each header that uses
the "fmt" or "format" paramters (grepped + awk). This revealed some
other errors. The NCP2222 dissector was missing a format string (not
a security vuln though).

Many dissectors used val_to_str with a constant (but empty) string,
these have been replaced by val_to_str_const. ASN.1 dissectors
were regenerated for this.

Minor: the mate plugin used "%X" instead of "%p" for a pointer type.

The ncp2222 dissector and wimax plugin gained modelines.

Change-Id: I7f3f6a3136116f9b251719830a39a7b21646f622
Reviewed-on: https://code.wireshark.org/review/2881
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-07-06 23:00:40 +00:00
Guy Harris cb16dff992 Get rid of more tvb_get_nstringz* calls.
Add an FT_STRINGZPAD type, for null-padded strings (typically
fixed-length fields, where the string can be up to the length of the
field, and is null-padded if it's shorter than that), and use it.  Use
IS_FT_STRING() in more cases, so that less code needs to know what types
are string types.

Add a tvb_get_stringzpad() routine, which gets null-padded strings.
Currently, it does the same thing that tvb_get_string_enc() does, but
that might change if we don't store string values as null-terminated
strings.

Change-Id: I46f56e130de8f419a19b56ded914e24cc7518a66
Reviewed-on: https://code.wireshark.org/review/1082
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-04-12 22:27:22 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Michael Mann bcd2ecfc94 Add FT_SYSTEM_ID for type checking
svn path=/trunk/; revision=54394
2013-12-23 17:57:57 +00:00
Jakub Zawadzki 12d1509aa1 Move struct _ftype_t + callback typedefs + free macro to ftypes-int.h
svn path=/trunk/; revision=53223
2013-11-10 13:14:09 +00:00
Michael Mann ee208c8dcc Add support for RELATIVE-OID ASN.1 type. Bug 9192 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9192)
From Ed Beroset.

svn path=/trunk/; revision=52393
2013-10-06 02:31:10 +00:00
Jakub Zawadzki c6669a3c63 dfilter: report warning if OR and AND logic operands are mixed without parentheses.
svn path=/trunk/; revision=51247
2013-08-10 17:49:28 +00:00
Jakub Zawadzki 9cfac1227d Replace hfinfo pointer to same_name_prev, with same_name_prev_id.
svn path=/trunk/; revision=51175
2013-08-06 20:53:47 +00:00
Jakub Zawadzki d6f249633a dfilter: move convertion to byte to seperate function
svn path=/trunk/; revision=50964
2013-07-28 08:41:26 +00:00
Michael Mann a87f47c02c Make many items filterable for Vines dissectors.
Add support for FT_VINES type.

svn path=/trunk/; revision=50962
2013-07-28 00:07:49 +00:00
Jakub Zawadzki 73aa1e7807 Support drange for functions
last think from bug #8979
+ fix semcheck.c:875: warning: signed and unsigned type in conditional expression

svn path=/trunk/; revision=50951
2013-07-27 19:14:34 +00:00
Jakub Zawadzki 1f4d76a6ca Some more work related to bug #8979 and previous commit
- Make http.location[0:4] == lower(http.location) behave the same as lower(http.location) == http.location[0:4]
- fix compiler errors + comments

svn path=/trunk/; revision=50950
2013-07-27 18:55:05 +00:00
Jakub Zawadzki da170f1d04 Fix bug #8979: Comparing function call and a range in the filter crashes Wireshark
store whole node, don't assume it's always STTYPE_FIELD

svn path=/trunk/; revision=50949
2013-07-27 17:17:15 +00:00
Evan Huus 5ede3bcde0 Follow-up to r50935: add support for 64-bit value strings in more places that
need it, I think this is all of them.

svn path=/trunk/; revision=50941
2013-07-26 23:51:00 +00:00
Anders Broman 7ad305365f type drange -> drange_t
explicit casts.

svn path=/trunk/; revision=48083
2013-03-05 06:16:45 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Guy Harris 835111692f From Richard Stearn: support for AX.25, including support for
LINKTYPE_AX25.

svn path=/trunk/; revision=44211
2012-08-02 16:54:43 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Jakub Zawadzki 6fff7c61f0 display filter: restore comparision of fields.
like:
  udp.srcport == udp.dstport
  frame.cap_len != frame.len
(probably you can use it for better ones)

part of bug #7263


svn path=/trunk/; revision=43069
2012-06-04 14:45:50 +00:00
Anders Broman d1c1455882 Fix warnings
svn path=/trunk/; revision=43046
2012-06-03 20:59:41 +00:00
Anders Broman 345b48d1ea Try to squelch warnings
svn path=/trunk/; revision=43019
2012-06-03 09:26:15 +00:00
Jakub Zawadzki 8fca2eb7e5 Add missing consts.
svn path=/trunk/; revision=42004
2012-04-10 10:20:20 +00:00
Anders Broman 7f96d94b7c From Gilbert Ramirez: When filtering on a single-byte byte-array-slice, using a normal hex string would be nice
svn path=/trunk/; revision=41232
2012-02-29 05:58:45 +00:00
Stig Bjørlykke 46c3fe0547 Prefer previous error message if not having hfinfo->strings,
because this may give more interesting information.

svn path=/trunk/; revision=39658
2011-10-28 20:13:56 +00:00
Gerald Combs 49b92440de More GLIB_CHECK_VERSION cleanups. Update the minimum GLib/GTK+ versions
in README.devloper. Remove g_gnuc.h since it's no longer needed. Remove
tvbuff_init(), tvbuff_cleanup(), reassemble_init(), and
reassemble_cleanup() since they were only used for older GLib versions
which didn't support GSlices. Assume we always support the "matches"
operator.

svn path=/trunk/; revision=37978
2011-07-11 20:32:19 +00:00
Guy Harris 053c583fda Add some additional routine variants that handle string encodings, and
make FT_STRING and FT_UINT_STRING handle string encodings.

Get rid of FT_EBCDIC in favor of FT_STRING with ENC_EBCDIC.

Add some URLs for DRDA.

Clean up some stuff in TN3270 and TN5250, including using ENC_ values
for proto_tree_add_item().

svn path=/trunk/; revision=37909
2011-07-05 23:59:23 +00:00
Alexis La Goutte 7d317e553b Add FT_EUI64 Field Type
* Remove proto_tree_add_eui64 function from 802.15.4 Dissector 
* Replace print_eui64/print_eui64 by eui64_to_str/get_eui64_name
* Update Documentation (README.dev)
* Add new function in libwireshark.def
* Support of encoding for tvb_eui64_to_str
* Use FT_EUI64 for ICMPv6, CAPWAP, Zbee ... dissector

svn path=/trunk/; revision=37015
2011-05-08 10:23:53 +00:00
Bill Meier 2891d9084d From Yaniv Kaul: some 'set but not used' compilation fixes;
From me:
 Use consistent indentation in the source file.

svn path=/trunk/; revision=36887
2011-04-27 04:24:44 +00:00
Bill Meier ede51600c7 Don't assign to a variable if the value won't be used: Coverity 817-821.
svn path=/trunk/; revision=36446
2011-04-04 15:31:33 +00:00