Referring to pcap_version[] doesn't do what you want on at least some

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.

svn path=/trunk/; revision=40138
This commit is contained in:
Guy Harris 2011-12-09 21:15:48 +00:00
parent f70480894c
commit e42d0d35d8
2 changed files with 20 additions and 24 deletions

View 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

View 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
}
/*