Commit Graph

38 Commits

Author SHA1 Message Date
Guy Harris 08f5044894 except: update some coments.
If KAZLIB_POSIX_THREADS isn't defined, we are still using thread support
- compiler and support library support for per-thread data, at least for
the stack of exception catchers.

Update and expand comments.
2022-01-11 21:05:35 -08:00
Guy Harris db27fb777a exceptions: make the exception handler stack per-thread.
This prevents the weird failures I saw on macOS in #17856; instead, it
should fail on *all* platforms with

    Unhandled exception ("epan/proto.c:8800: failed assertion "DISSECTOR_ASSERT_NOT_REACHED"", group=1, code=6)

(which it does on macOS 11.6/Xcode 12.5.1 and Windows 10/VS 2019
16.11.8; according to

https://en.wikipedia.org/w/index.php?title=Thread-local_storage&oldid=1064900318#C_and_C++

the major UN*X C compilers support __thread and the major Windows C
compilers support __declspec(thread).).

@jvalverde: on branches that require C11/C++11 support, we could perhaps
just use _Thread_local for C and thread_local for C++.  Note that
<thread.h> is optional in C11, and macOS 11.6/Xcode 12.5.1 does not
appear to include it.)

This does not *fix* the aforementioned issue; to do *that* we need to do
TRY in the register-dissectors thread code.  I'm committing this
separately because it fixes a bug in our exception package that could
cause all sorts of randomness now and in the future - what we're doing
now is Just Wrong.

(Yes, there's code to support per-thread exception handler stacks *on
platforms with pthreads*, but this is simpler *and* also works on
Windows.)
2022-01-11 05:00:42 +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 9ba97d12d6 Add ws_debug() and use it
Replace most instances of ws_debug_printf() except in
epan/dissectors and dissector plugins.

Some replacements use printf(), some use ws_debug(), and
some were removed because they were dead or judged to be
temporary.
2021-05-24 01:13:19 +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
Peter Wu 9c61757dc2 except: detect exception stack corruption
Valgrind found an invalid read in the capture from Bug 15173 which was
not detected by ASAN, probably because 'top' pointed to a valid stack
address. Try to catch such issues with an explicit invariant check.

Change-Id: I3e2d90f053209c133ea2edc9c7990a2fd39bd236
Ping-Bug: 15189
Reviewed-on: https://code.wireshark.org/review/30101
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-10 04:08:17 +00:00
Guy Harris 494508f2d0 Clean up REPORT_DISSECTOR_BUG().
Have it take a format and argument list as arguments, and have the
formatting done inside the reporting code.  That way, we're not relying
on any particular wmem scope working.

If WIRESHARK_ABORT_ON_DISSECTOR_BUG is set, try to add the message to
the crash information (currently only supported in macOS), and print it
to the standard error, before crashing.  We won't necessarily have a
usable crash dump to analyze, so we can't rely on that to find the cause
of the crash.

Ping-Bug: 14490
Change-Id: I2b39169c45c84f2ada31efa1d413bd28c140f8f4
Reviewed-on: https://code.wireshark.org/review/26643
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-03-25 23:49:35 +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
Peter Wu 57b2a84f3d Use a single WS_NORETURN macro
Having to define two macros for marking a function as never returning
seems a bit redundant. Merge the MSVC and GCC-like attributes into a
single WS_NORETURN.

Tested with Clang 3.7.1, GCC 4.4.7 and even GCC 4.1.2 using this small
program (-Wall -Wextra, the first two generate warnings for
uninitialized variables, the last one compiles without warnings):

    #include <stdlib.h>
    __attribute__((noreturn)) void foo() { exit(1); }
    __attribute__((noreturn)) void bar();
    void bar() { exit(1); }
    int main() {
      int j, i;
      if (i) { bar(); return j; }
      foo();
      return j;
    }

Change-Id: I7d19c15e61b8f8fa4936864407199c4109f8cc82
Reviewed-on: https://code.wireshark.org/review/14822
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-04-08 17:34:10 +00:00
Guy Harris a365fb8316 Print unsigned long values with %lu, not %ld.
Change-Id: Ic437f5ec918c1cd4d39eb27e0a4fafb2a2f4b244
Reviewed-on: https://code.wireshark.org/review/8782
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-06-06 01:40:08 +00:00
Bill Meier e88a11f5c9 (Trivial) Fix printf-related 'Mismatch on sign' warnings
Found by MSVC2013 Code Analysis

Change-Id: I58063946dd558e98308c87b36eeac0ddbe1a6e79
Reviewed-on: https://code.wireshark.org/review/7045
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2015-02-09 18:57:14 +00:00
Dario Lombardo 63ebe918d9 Removed duplicated #include lines
Change-Id: I9cafa3cd5c74121168777d8c656e7e94e89efd3c
Reviewed-on: https://code.wireshark.org/review/6065
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-12-28 00:02:39 +00:00
Guy Harris c3f14ab3d4 Don't use toupper() in the test program.
We're not including ctype.h in the test program, so don't use toupper().
The test program might not be built with GLib, so don't use
g_ascii_toupper(), either.  Just compare against both 'Y' and 'y'.

Change-Id: Iabc04a5fecb04110c0d16b24a047de72eabbb2bc
Reviewed-on: https://code.wireshark.org/review/4870
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-20 09:04:44 +00:00
Guy Harris 19b7819694 Get rid of unnecessary includes of ctype.h.
Change-Id: Ibb194cd839d174af9c96f7bb1e2941b3dd6c1ce1
Reviewed-on: https://code.wireshark.org/review/4797
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-10-17 23:31:20 +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
Alexis La Goutte ea227de9e2 Fix indent (Use 4spaces) and modelines info
svn path=/trunk/; revision=54967
2014-01-26 18:24:45 +00:00
Alexis La Goutte c6022b3b85 Drop support of Visual Studio 2005
* Remove _MSC_VER < 1500 check
* Cleanup config.nmake

See http://www.wireshark.org/lists/wireshark-dev/201305/msg00159.html

svn path=/trunk/; revision=54965
2014-01-26 12:56:32 +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
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
Stig Bjørlykke ffd28912d3 Another fix for building with MSVC2005.
The previous fixes in r37728 and r37730 did build a wireshark which was
unable to use the native windows file dialog (GetOpenFileName).

svn path=/trunk/; revision=38299
2011-08-01 12:38:58 +00:00
Guy Harris e654a29b1c config.h is now included, and it defines _WIN32_WINNT.
svn path=/trunk/; revision=35992
2011-02-17 23:36:39 +00:00
Guy Harris b4f663a29b On Windows, try putting __declspec(noreturn) in front of declarations of
routines that don't return.  (This requires that some files include
config.h to get WS_MSVC_NORETURN declared properly.)

svn path=/trunk/; revision=35989
2011-02-17 23:11:49 +00:00
Kovarththanan Rajaratnam c88f493d4d Cleanup rcsids
svn path=/trunk/; revision=30369
2009-10-06 15:07:52 +00:00
Kovarththanan Rajaratnam 5417a21bac As pointed out by Guy, we should probably explain why the gulong -> size_t cast is 'safe'
svn path=/trunk/; revision=29458
2009-08-17 20:14:59 +00:00
Kovarththanan Rajaratnam e4e9b91275 Add proper type cast.
Thanks to Martin for reporting this.

svn path=/trunk/; revision=29451
2009-08-17 04:23:47 +00:00
Kovarththanan Rajaratnam 154de60393 Switch over to using GLib's g_malloc/g_free in the name of consistency.
svn path=/trunk/; revision=29430
2009-08-15 09:13:16 +00:00
Gerald Combs 6c99cf5519 From Kovarththanan Rajaratnam via bug 3506:
The exception throwing code in except.c/h should be annotated with
"noreturn" to indicate that they never return. Running static analysis
on Wireshark without this annotation causes a lot of false positives
since these analyzers assume that the exception handling code are
ordinary functions that will eventually return.

svn path=/trunk/; revision=29246
2009-07-30 17:54:58 +00:00
Guy Harris ad1d82b541 Include <glib.h> to declare g_vsnprintf().
svn path=/trunk/; revision=23768
2007-12-05 10:35:37 +00:00
Guy Harris 3af2d0708a Use g_vsnprintf(), not vsprintf(), for safety's sake.
svn path=/trunk/; revision=23766
2007-12-05 10:30:38 +00:00
Ulf Lamping 6f2c4c84c1 Win32: call an existing debugger if a DissectorError is thrown. This preserves the call stack of the bug making debugging much easier.
This can't be done in every error throwing case, as e.g. throwing a ReportedBoundsError might happen a lot even if no bugs are involved. Anyway, extending this to other errors can be done manually while debugging.

svn path=/trunk/; revision=17072
2006-01-22 16:32:45 +00:00
Tomas Kukosa 0539569e1b get rid of warnings about qualifier discarding
svn path=/trunk/; revision=16017
2005-09-27 06:09:14 +00:00
Guy Harris f618b54d36 Support throwing an exception with a null message pointer, and have the
message not be const (as we generate messages with "g_strdup_sprintf()",
which means they need to be freed; using a null message means that we
don't have to use a special string for exceptions with no message, and
don't have to worry about not freeing that).

Have THROW() throw an exception with a null message pointer.  (This
means that you crash if you throw DissectorError with THROW().  Don't do
that - it means you don't get a more detailed explanation of the
dissector problem.  Use the DISSECTOR_ASSERT, etc. macros in
epan/proto.h instead.)

Free the exception message for DissectorError, as it's mallocated.

svn path=/trunk/; revision=15250
2005-08-06 19:58:45 +00:00
Gerald Combs 13fd96b13d Remove some unneeded backslashes.
svn path=/trunk/; revision=12857
2004-12-29 16:25:06 +00:00
Gerald Combs ee11576536 Remove some macros that were making the "splint" utility throw a fit.
svn path=/trunk/; revision=12849
2004-12-28 19:59:50 +00:00
Guy Harris 8a8b883450 Set the svn:eol-style property on all text files to "native", so that
they have LF at the end of the line on UN*X and CR/LF on Windows;
hopefully this means that if a CR/LF version is checked in on Windows,
the CRs will be stripped so that they show up only when checked out on
Windows, not on UN*X.

svn path=/trunk/; revision=11400
2004-07-18 00:24:25 +00:00
Jörg Mayer 48be4e530d Removed trailing whitespaces from .h and .c files using the
winapi_cleanup tool written by Patrik Stridvall for the wine
project.

svn path=/trunk/; revision=6116
2002-08-28 20:41:00 +00:00
Gilbert Ramirez 52d5904afd Fix for Kazlib exception code:
Defect number: 0011
Date: Jul 26 2001
Releases of Kazlib affected: 1.10 through 1.19
Status: Fixed in 1.20
Modules affected: except.c
Description: Members of the except_t structure needed to be declared
    volatile because the structure is automatically allocated in the
    except macro, modified after a setjmp() takes place, and accessed
    after control returns via longjmp.
Solution: Upgrade to 1.20 or backpatch the fix.

svn path=/trunk/; revision=3793
2001-07-27 16:20:39 +00:00
Gilbert Ramirez 83ec54675c First step in moving core Ethereal routines to libepan.
svn path=/trunk/; revision=2458
2000-09-27 04:55:05 +00:00