https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7850
Summary: Add error handler to munmap() failure in emem.c
Product: Wireshark
Version: 1.8.2
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: Low
Component: Common utilities (libwsutil)
AssignedTo: bugzilla-admin@xxxxxxxxxxxxx
ReportedBy: wp02855@xxxxxxxxx
Created attachment 9341
--> https://bugs.wireshark.org/bugzilla/attachment.cgi?id=9341
contains patch (diff -u) for emem.c for munmap()
Build Information:
odie:/usr/local/src/wireshark-1.8.2 # ./wireshark -v
wireshark 1.8.2 (SVN Rev Unknown from unknown)
Copyright 1998-2012 Gerald Combs <gerald@xxxxxxxxxxxxx> and contributors.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiled (64-bit) with GTK+ 2.22.1, with Cairo 1.10.2, with Pango 1.28.3, with
GLib 2.28.0, with libpcap, with libz 1.2.5, without POSIX capabilities, without
SMI, without c-ares, without ADNS, without Lua, without Python, with GnuTLS
2.8.6, with Gcrypt 1.4.6, with MIT Kerberos, without GeoIP, without PortAudio,
with AirPcap.
Running on Linux 2.6.37.6-0.7-desktop, with locale POSIX, with libpcap version
1.1.1, with libz 1.2.5, GnuTLS 2.8.6, Gcrypt 1.4.6, without AirPcap.
Built using gcc 4.5.1 20101208 [gcc-4_5-branch revision 167585].
--
Wireshark-1.8.2/1.8.3 sanity/error checking for munmap()
in file epan/emem.c
In reviewing file 'emem.c' in directory 'epan', I found that
while calls to mmap() are checked for error conditions, but
munmap() call(s) are not. In reading code for wireshark 1.8.2
and 1.8.3, while error recovery is not possible for
munmap(), it should print an error message to stderr as
a informational warning.
It also provides a check for the return value from sysconf()
as a return value of -1 and errno != 0 indicates a failure
of sysconf().
Here is the patch code for emem.c:
--- emem.c.orig 2012-10-10 18:31:16.060811938 -0700
+++ emem.c 2012-10-10 21:49:34.088146643 -0700
@@ -361,6 +361,8 @@
#elif defined(USE_GUARD_PAGES)
pagesize = sysconf(_SC_PAGESIZE);
+ if (pagesize == -1)
+ fprintf(stderr, "Warning: call to sysconf() for _SC_PAGESIZE
has failed...\n");
#ifdef NEED_DEV_ZERO
dev_zero_fd = ws_open("/dev/zero", O_RDWR);
g_assert(dev_zero_fd != -1);
@@ -678,7 +680,13 @@
#if defined (_WIN32)
VirtualFree(npc->buf, 0, MEM_RELEASE);
#elif defined(USE_GUARD_PAGES)
- munmap(npc->buf, npc->amount_free_init);
+
+ /* we cannot recover from a munmap() failure, but we */
+ /* can print an informative error message to stderr */
+
+ if (munmap(npc->buf, npc->amount_free_init) != 0)
+ fprintf(stderr, "Warning: Unable to unmap memory chunk which
has address %p and size %u\n",
+ npc->buf, npc->amount_free_init);
#else
g_free(npc->buf);
#endif
--
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.