Referring to pcap_version[] doesn't do what you want on at least some
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 9 Dec 2011 21:15:48 +0000 (21:15 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 9 Dec 2011 21:15:48 +0000 (21:15 +0000)
UN*Xes (Fedora 16 and probably other Linux distributions, probably at
least some if not all other ELF-based systems, and perhaps also Mac OS
X), and causes problems if pcap_version[] has a different length in the
libpcap with which the executable was built and the libpcap with which
it's run, so we avoid using it for now.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@40138 f5534014-38df-0310-8fa8-9805f1628bb7

acinclude.m4
capture-pcap-util-unix.c

index 2a6f6e2..7409bd7 100644 (file)
@@ -493,25 +493,7 @@ and did you also install that package?]]))
        # libpcap.
        #
        ac_save_LIBS="$LIBS"
-       AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
        LIBS="$PCAP_LIBS $SOCKET_LIBS $NSL_LIBS $LIBS"
-       AC_TRY_LINK(
-          [
-#      include <stdio.h>
-       extern char *pcap_version;
-          ],
-          [
-       printf ("%s\n", pcap_version);
-          ],
-          ac_cv_pcap_version_defined=yes,
-          ac_cv_pcap_version_defined=no,
-          [echo $ac_n "cross compiling; assumed OK... $ac_c"])
-       if test "$ac_cv_pcap_version_defined" = yes ; then
-               AC_MSG_RESULT(yes)
-               AC_DEFINE(HAVE_PCAP_VERSION, 1, [Define if libpcap version is known])
-       else
-               AC_MSG_RESULT(no)
-       fi
        AC_CHECK_FUNCS(pcap_open_dead pcap_freecode)
        #
        # pcap_breakloop may be present in the library but not declared
index 6ea083c..a2bbd0f 100644 (file)
@@ -333,13 +333,27 @@ cant_get_if_list_error_message(const char *err_str)
 void
 get_compiled_pcap_version(GString *str)
 {
-#ifdef HAVE_PCAP_VERSION
-       extern char pcap_version[];
-
-       g_string_append_printf(str, "with libpcap %s", pcap_version);
-#else
+       /*
+        * NOTE: in *some* flavors of UN*X, the data from a shared
+        * library might be linked into executable images that are
+        * linked with that shared library, in which case you could
+        * look at pcap_version[] to get the version with which
+        * the program was compiled.
+        *
+        * In other flavors of UN*X, that doesn't happen, so
+        * pcap_version[] gives you the version the program is
+        * running with, not the version it was built with, and,
+        * in at least some of them, if the length of a data item
+        * referred to by the executable - such as the pcap_version[]
+        * string - isn't the same in the version of the library
+        * with which the program was built and the version with
+        * which it was run, the run-time linker will complain,
+        * which is Not Good.
+        *
+        * So, for now, we just give up on reporting the version
+        * of libpcap with which we were compiled.
+        */
        g_string_append(str, "with libpcap (version unknown)");
-#endif
 }
 
 /*