Commit Graph

83 Commits

Author SHA1 Message Date
João Valverde 40ec1adfb0 S7Comm: Fix invalid UTF-8 value string chars
Fixes #18533.
2022-10-26 01:42:43 +01:00
Moshe Kaplan 69d54d6f8e Corrects repeated words throughout the code.
Repeated words were found with:
egrep "(\b[a-zA-Z]+) +\1\b" . -Ir
and then manually reviewed.
Non-displayed strings (e.g., in comments)
were also corrected, to ease future review.
2021-12-22 11:01:11 +00:00
João Valverde c5a19582e4 epan: Convert to use stdio.h from GLib
Replace:
    g_snprintf() -> snprintf()
    g_vsnprintf() -> vsnprintf()
    g_strdup_printf() -> ws_strdup_printf()
    g_strdup_vprintf() -> ws_strdup_vprintf()

This is more portable, user-friendly and faster on platforms
where GLib does not like the native I/O.

Adjust the format string to use macros from intypes.h.
2021-12-19 19:29:53 +00:00
João Valverde 133b0c583f Move epan/wmem/wmem_scopes.h to epan/
This header was installed incorrectly to epan/wmem_scopes.h.

Instead of creating additional installation rules for a single
header in a subfolder (kept for backward compatibility) just
rename the standard "epan/wmem/wmem.h" include to
"epan/wmem_scopes.h" and fix the documentation.

Now the header is installed *correctly* to epan/wmem_scopes.h.
2021-07-26 14:56:11 +00:00
João Valverde 0e50979b3f Replace g_assert() with ws_assert() 2021-06-19 01:23:31 +00:00
João Valverde 39df3ae3c0 Replace g_log() calls with ws_log() 2021-06-16 12:50:27 +00: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
Tom Hughes 99c62bf797 Add support for extended 64 bit value to string matching
This adds val64_string_ext to parallel value_string_ext in the
same way that val64_string parallels value_string.

Change-Id: Iadbfc49f5a4540000ed92fd0469e8d273911e97e
Reviewed-on: https://code.wireshark.org/review/30385
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-27 05:34:59 +00:00
Gerald Combs 8f08a4e74e Try to discourage the use of APIs via counting.
Add the ability to specify maximum function counts for each group to
checkAPIs. Add maximum counts for the "termoutput" and "abort" groups
where needed. Show summaries in various checkAPI targets.

Switch uses of ws_g_warning back to plain g_warning.

Change-Id: I5cbddc8c671729e424eed8551f69116d16491976
Reviewed-on: https://code.wireshark.org/review/29721
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-09-19 16:07:03 +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 98558fd81c Fix buffer overrun in try_bytesprefix_to_str
bytes_string list contains a list of prefixes to match, not the other
way round (matching prefixes in the list).

Bug: 13479
Change-Id: Ie625dc5db30bd55158d688a0101f35d0bf6906af
Fixes: v2.3.0rc0-2644-g540b555729 ("Introduce "bytes_string" type, similar to "value_string"")
Reviewed-on: https://code.wireshark.org/review/20532
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-13 21:46:38 +00:00
Peter Wu 540b555729 Introduce "bytes_string" type, similar to "value_string"
In order to map arbitrary byte buffers to strings, introduce a new
"bytes_string" type. Since "bytes_to_str" is already used for other
purposes, name the generic function "bytesval_to_str" instead similar to
the name( "val_to_str").

Accept "size_t" as length parameter since this is what is returned by
the "sizeof" operator. Do not add a "try_bytesval_to_str_idx" variant
since this pattern is not needed for now. Add a variant to match the
prefix since this is currently expected by the ISAKMP dissector.

Change-Id: I6d790325e85d9fb1384330f28a8c36e2057fdf30
Reviewed-on: https://code.wireshark.org/review/20386
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2017-03-08 23:04:12 +00:00
Michael Mann 600eca15fe Allow up to 64-bit values to use BASE_RANGE_STRING.
Change-Id: Iea69b5ef533b9b524a624b96bf82e178fd428ce9
Reviewed-on: https://code.wireshark.org/review/16934
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-08-07 07:39:12 +00:00
Michael Mann 907d49483d Fix some of the checkAPIs.pl warnings for g_warning.
1. Create ws_g_warning for legitimate uses of g_warning
2. Use proto_tree_add_debug_text
3. Comment some out

Change-Id: Ida044bf40286b955fdd529c4f9907c8e09b3d7c5
Reviewed-on: https://code.wireshark.org/review/16678
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-26 04:08:50 +00:00
João Valverde 94c0f91085 Fix value_string_ext_free() constness
Don't declare destructor as taking a const argument.

Change-Id: I9badfe400718bef41a0e0a00d4b3d1b0bb2879d1
Reviewed-on: https://code.wireshark.org/review/16342
Reviewed-by: João Valverde <j@v6e.pt>
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-07-08 20:01:02 +00:00
Guy Harris 2275e02730 Revert "Simplify val_to_str[_ext] implementation."
This reverts commit 1d0a974932.

This appears to be causing a crash - and the code in val_to_str() isn't just a copy of the code in val_to_str_wmem(), as it doesn't do a wmem allocation if try_val_to_str(), which *doesn't* use wmem, succeeds.

Change-Id: I40e9e8b4ed0a1c66e20ab4bd827ac51c3fac85ff
Reviewed-on: https://code.wireshark.org/review/15351
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-05-11 04:22:26 +00:00
Michael Mann 1d0a974932 Simplify val_to_str[_ext] implementation.
All val_to_str API use wmem, so just call the wmem function version
passing packet_scope instead of copying it.

Change-Id: Ib58b6b702fbaf5a81cc445bd01ef1a523774be6e
Reviewed-on: https://code.wireshark.org/review/15348
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-05-11 03:16:59 +00:00
Michael Mann 7ced085550 emem is dead! Long live wmem!
Change-Id: Iddd1200e62bf3200cb1a68408378dd9d47120b77
Reviewed-on: https://code.wireshark.org/review/6939
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Evan Huus <eapache@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-02-04 06:59:55 +00:00
Michael Mann 90a76e0d51 Convert val_to_str -> val_to_str_wmem.
This is mostly for GUI usage, but a few dissectors needed some "non-packet scope" conversions.

val_to_str officially now uses wmem_packet_scope()

Change-Id: Ic9413eeb3406d7a7683222b86709f3675d628d81
Reviewed-on: https://code.wireshark.org/review/6933
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-02-04 06:58:49 +00:00
Michael Mann b635997624 Convert val_to_str_ext -> val_to_str_ext_wmem for calls that don't have valid packet scope (GUI).
val_to_str_ext now officially uses wmem_packet_scope().

Removed const from val_to_str[_ext]_wmem return value since it's not really constant.

Created utility functions in qt_ui_utils.h to help with the new memory management for its GUI.

Change-Id: Idf2ce4a4ce78d628b2269ad23a3a48fbfc9c077c
Reviewed-on: https://code.wireshark.org/review/6926
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-02-03 13:03:32 +00:00
Michael Mann 6db0a358ea Create wmem versions of val_to_str and val_to_str_ext
These will be used to replace cases where packet-scope isn't valid for val_to_str/val_to_str_ext calls

Change-Id: Ie8a4c423a8608548c837c1ae7edde52c4d728340
Reviewed-on: https://code.wireshark.org/review/6880
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-02-02 12:56:32 +00:00
Michael Mann dc6482b7c2 Convert the value string APIs that only currently have packet-scope use to wmem.
Change-Id: I36942493ce73b49e7257edea967eddf22f21f58e
Reviewed-on: https://code.wireshark.org/review/6879
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-31 13:13:17 +00:00
Kevin Cox 34e413f66d Make value_string_ext const-correct.
There is still some const-incorrect usage of them but those can be ironed
out after this change has been made.

Change-Id: Iba0631c804bdab34d7c0232b49967130e3370488
Reviewed-on: https://code.wireshark.org/review/3199
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-07-27 22:02:42 +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
Bill Meier 099efcf5eb Value_string.h: Minor changes to comment text
value_string.c:  value_string_ext_validate() always fails on Windows
                   when called from a different DLL (i.e. a plugin).
                   So: Add #ifndef _WIN32 around the offending code.

svn path=/trunk/; revision=54047
2013-12-13 14:39:19 +00:00
Bill Meier 7727623d8c Do some constification;
Create/use value_string_ext_free();
Display certain numbers also as hex in the
   "forced to fall back to linear search: ..." value-string warning msg
Add editor-modelines to some files;
Do some whitespace changes.

svn path=/trunk/; revision=53484
2013-11-21 18:46:40 +00:00
Evan Huus c1dd5d3882 Replace some val_to_str calls with the equivalent val_to_str_const calls (and
implement rval_to_str_const to do this). The format-strings didn't have any
parameter specifiers in them, so they were clearly never used (or they would
have blown up) but still a bug.

This is one of the first steps towards converting val_to_str and friends to
wmem. I'm honestly not sure what the best approach is for the API in this case:
the vast majority of usage is within dissectors, so just hard-coding packet
scope (the way they currently hard-code ep_ scope) doesn't look terrible, but
there are *some* uses in taps and other places that will need to be converted to
something else if we go that route. Adding a wmem_pool parameter just for the
uncommon case seems a bit like overkill, though perhaps it is the right thing to
do.

svn path=/trunk/; revision=52264
2013-09-29 12:44:50 +00:00
Guy Harris 9e47411488 Include config.h first; it defines _FILE_OFFSET_BITS, and if some system
header later causes it to be redefined - as happens on my Solaris 11
virtual machine - we get a redefinition warning, which gets treated as
an error.

svn path=/trunk/; revision=51349
2013-08-14 01:15:59 +00:00
Evan Huus 6e3a30794e Add 64-bit value strings and the appropriate tooling (including yet another
overloaded use of the DISPLAY field). Thanks to Jakub for pointing out I'd done
this wrong the first time (months ago in r49357).

Fixes severity display for collectd protocol, originally filed at:
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8472

svn path=/trunk/; revision=50935
2013-07-26 21:51:39 +00:00
Evan Huus afa7538f12 Revert part of r50415. As pointed out by Jakub, some of the value_string
functions are called when no dissection is going on, and so can't use
wmem_packet_scope().

svn path=/trunk/; revision=50428
2013-07-06 23:53:09 +00:00
Evan Huus bae9597ca7 Wmem-ify value-strings. Another ~10KB gone.
svn path=/trunk/; revision=50415
2013-07-06 18:25:27 +00:00
Evan Huus 178fc8852a Note to self: stop using 'index' as a variable name, it triggers -Wshadow on
some platforms. You'd think I'd have learned by now.

svn path=/trunk/; revision=48646
2013-03-30 00:11:00 +00:00
Evan Huus d155b0da19 Implement str_to_val, opposite of val_to_str for value_strings.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8467

svn path=/trunk/; revision=48645
2013-03-29 23:23:28 +00:00
Evan Huus a0d107beec Remove decode_enumerated_bitfield and decode_enumerated_bitfield_shifted.
Effectively inline the only remain call (and replace a static buffer with ep
memory). Much of the NFS dissector needs to be converted to use named fields
at which point this code can go away, but that's a much bigger job.

Also, add modelines to packet-nfs.c and mark some internal value_string
functions as WS_DLL_LOCAL.

svn path=/trunk/; revision=48635
2013-03-29 02:34:23 +00:00
Evan Huus 37600a157b Rename value string (and similar) functions to use a consistent pattern. This
was done using textual search+replace, not anything syntax-aware, so presumably
it got most comments as well (except where there were typos).

Use a consistent coding style, and make proper use of the WS_DLL_* defines.

Group the functions appropriately in the header.

I ended up getting rid of most of the explanatory comments since many of them
duplicated what was in the value_string.c file (and were out of sync with the
recent updates I made to those in r48633). Presumably most of the comments
should be in the .h file not the .c file, but there's enough churn ahead that
it's not worth fixing yet.

Part of https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8467

svn path=/trunk/; revision=48634
2013-03-29 00:26:23 +00:00
Evan Huus 6f19d87f4e Greatly clean up value_string.c
- use consistent indentation and coding style
 - add modelines
 - replace some g_assert calls with DISSECTOR_ASSERT where it makes sense
 - group related functions together and simplify many comments by referring to
   the 'normal' value_string as the canonical version

svn path=/trunk/; revision=48633
2013-03-28 22:02:04 +00:00
Guy Harris 94af602582 Give better diagnostics for "Extended value string XXX forced to fall
back to linear search", to make it easier to find the out-of-order
entries.

svn path=/trunk/; revision=48555
2013-03-26 00:37:03 +00:00
Bill Meier 0df5a9390d From beroset:
remove C++ incompatibilities
 https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 attachment #10397

svn path=/trunk/; revision=48438
2013-03-20 01:18:10 +00:00
Evan Huus 1a684e6adf Warn if an extended value string falls back to linear search.
See https://www.wireshark.org/lists/wireshark-dev/201303/msg00179.html

svn path=/trunk/; revision=48415
2013-03-19 14:53:44 +00:00
Evan Huus 574d1ceec3 Revert warning that seems to have been accidentally included in r48319.
svn path=/trunk/; revision=48323
2013-03-15 17:56:27 +00:00
Anders Broman 54eb4a6cec [-Wmissing-prototypes]
Use explicit casts.

svn path=/trunk/; revision=48319
2013-03-15 16:39:30 +00:00
Jakub Zawadzki c5a71b1006 String passed to val_to_str() must have int format specifier (%u, %d, %x, and so on...).
Fix some cases (easy to grep) by call to val_to_str_const().

svn path=/trunk/; revision=47807
2013-02-21 21:04:59 +00:00
Guy Harris 8ed7a73e22 Fix a bunch of warnings.
Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
sizeof.

Cast away some implicit 64-bit-to-32-bit conversion errors due to use of
strtol() and strtoul().

Change some data types to avoid those implicit conversion warnings.

When assigning a constant to a float, make sure the constant isn't a
double, by appending "f" to the constant.

Constify a bunch of variables, parameters, and return values to
eliminate warnings due to strings being given const qualifiers.  Cast
away those warnings in some cases where an API we don't control forces
us to do so.

Enable a bunch of additional warnings by default.  Note why at least
some of the other warnings aren't enabled.

randpkt.c and text2pcap.c are used to build programs, so they don't need
to be in EXTRA_DIST.

If the user specifies --enable-warnings-as-errors, add -Werror *even if
the user specified --enable-extra-gcc-flags; assume they know what
they're doing and are willing to have the compile fail due to the extra
GCC warnings being treated as errors.

svn path=/trunk/; revision=46748
2012-12-26 05:57:06 +00:00
Jeff Morriss 7033cc7220 Fix some indentation.
svn path=/trunk/; revision=46512
2012-12-12 01:50:44 +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
Bill Meier 0035a9076b Force extended value string linear search (not binary search) in one case:
Fixed: { -2, -1, 0, 1, 3} (note gap) used a binary search (which would fail);

 Note:  { -2, -1, 0, 1, 2 ,3 } (no gap) allowed; will still do a direct access;

Also: Add a comment to README.developer extended value string section.

svn path=/trunk/; revision=44659
2012-08-24 20:44:33 +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
Bill Meier b017f7c22d Fix a typo.
svn path=/trunk/; revision=42201
2012-04-23 02:37:35 +00:00
Jakub Zawadzki 6aa7c2d371 Try to fix:
value_string.c(175) : warning C4244: '=' : conversion from '__int64' to 'gint', possible loss of data

svn path=/trunk/; revision=36931
2011-04-28 11:53:29 +00:00
Jakub Zawadzki 1ea1e9fef2 Change value_string_ext->_vs_match to return value_string struct (instead of strptr),
Now index can be easily calculated so remove idx pointer from all match functions.

Just in case change names if someone is using wireshark internals.

svn path=/trunk/; revision=36930
2011-04-28 11:15:46 +00:00