summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ConfigureChecks.cmake2
-rw-r--r--acinclude.m416
-rw-r--r--asn1/kerberos/packet-kerberos-template.c1
-rw-r--r--asn1/kerberos/packet-kerberos-template.h2
-rw-r--r--cmakeconfig.h.in4
-rw-r--r--config.h.win324
-rw-r--r--configure.ac6
-rw-r--r--epan/addr_resolv.c75
-rw-r--r--epan/dissectors/packet-kerberos.c7
-rw-r--r--epan/dissectors/packet-kerberos.h2
10 files changed, 75 insertions, 44 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 228da5758c..911d487cb7 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -76,7 +76,7 @@ cmake_pop_check_state()
# and there's not actually a function named floorl()
#
check_symbol_exists("floorl" "math.h" HAVE_FLOORL)
-check_function_exists("gethostbyname2" HAVE_GETHOSTBYNAME2)
+check_function_exists("getaddrinfo" HAVE_GETADDRINFO)
check_function_exists("getopt_long" HAVE_GETOPT_LONG)
if(HAVE_GETOPT_LONG)
if(HAVE_GETOPT_H)
diff --git a/acinclude.m4 b/acinclude.m4
index de635e1520..dba599c2ce 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -268,25 +268,27 @@ yes
])
#
-# AC_WIRESHARK_GETHOSTBY_LIB_CHECK
+# AC_WIRESHARK_GETADDRINFO_LIB_CHECK
#
-# Checks whether we need "-lnsl" to get "gethostby*()", which we use
-# in "resolv.c".
+# Checks whether we need "-lnsl" to get "getaddrinfo()", which we use
+# in "addr_resolv.c".
#
# Adapted from stuff in the AC_PATH_XTRA macro in "acspecific.m4" in
# GNU Autoconf 2.13; the comment came from there.
# Done by Guy Harris <guy@alum.mit.edu> on 2000-01-14.
#
-AC_DEFUN([AC_WIRESHARK_GETHOSTBY_LIB_CHECK],
+AC_DEFUN([AC_WIRESHARK_GETADDRINFO_LIB_CHECK],
[
+ # Comments below apply to gethostbyname(), from which this was
+ # migrated:
# msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
# to get the SysV transport functions.
# chad@anasazi.com says the Pyramid MIS-ES running DC/OSx (SVR4)
# needs -lnsl.
# The nsl library prevents programs from opening the X display
# on Irix 5.2, according to dickey@clark.net.
- AC_CHECK_FUNC(gethostbyname, ,
- AC_CHECK_LIB(nsl, gethostbyname, NSL_LIBS="-lnsl"))
+ AC_CHECK_FUNC(getaddrinfo, ,
+ AC_CHECK_LIB(nsl, getaddrinfo, NSL_LIBS="-lnsl"))
AC_SUBST(NSL_LIBS)
])
@@ -294,7 +296,7 @@ AC_DEFUN([AC_WIRESHARK_GETHOSTBY_LIB_CHECK],
# AC_WIRESHARK_SOCKET_LIB_CHECK
#
# Checks whether we need "-lsocket" to get "socket()", which is used
-# by libpcap on some platforms - and, in effect, "gethostby*()" on
+# by libpcap on some platforms - and, in effect, "getaddrinfo()" on
# most if not all platforms (so that it can use NIS or DNS or...
# to look up host names).
#
diff --git a/asn1/kerberos/packet-kerberos-template.c b/asn1/kerberos/packet-kerberos-template.c
index ed3137dc40..9a111da625 100644
--- a/asn1/kerberos/packet-kerberos-template.c
+++ b/asn1/kerberos/packet-kerberos-template.c
@@ -261,6 +261,7 @@ read_keytab_file_from_preferences(void)
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
#ifdef _WIN32
/* prevent redefinition warnings in kfw-2.5\inc\win_mac.h */
+#undef HAVE_GETADDRINFO
#undef HAVE_STDARG_H
#undef HAVE_STDLIB_H
#undef HAVE_STRING_H
diff --git a/asn1/kerberos/packet-kerberos-template.h b/asn1/kerberos/packet-kerberos-template.h
index 64e2ae8263..871a1211a1 100644
--- a/asn1/kerberos/packet-kerberos-template.h
+++ b/asn1/kerberos/packet-kerberos-template.h
@@ -60,7 +60,7 @@ int dissect_krb5_cname(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *
int dissect_krb5_realm(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_);
guint32 kerberos_output_keytype(void);
-guint get_krb_pdu_len(packet_info *, tvbuff_t *tvb, int offset);
+guint get_krb_pdu_len(packet_info *, tvbuff_t *tvb, int offset, void *data _U_);
gint kerberos_rm_to_reclen(guint krb_rm);
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
index 73699befdb..fcf18e4d0d 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -71,8 +71,8 @@
/* Define if you have the 'floorl' function. */
#cmakedefine HAVE_FLOORL 1
-/* Define to 1 if you have the `gethostbyname2' function. */
-#cmakedefine HAVE_GETHOSTBYNAME2 1
+/* Define to 1 if you have the `getaddrinfo' function. */
+#cmakedefine HAVE_GETADDRINFO 1
/* Define to 1 if you have the getopt_long function. */
#cmakedefine HAVE_GETOPT_LONG 1
diff --git a/config.h.win32 b/config.h.win32
index e8ff4cf2f7..549a1885aa 100644
--- a/config.h.win32
+++ b/config.h.win32
@@ -89,8 +89,8 @@
/* Define if you have the floorl function. */
#define HAVE_FLOORL 1
-/* Define if you have the gethostbyname2 function. */
-/* #undef HAVE_GETHOSTBYNAME2 */
+/* Define if you have the getaddrinfo function. */
+#define HAVE_GETADDRINFO 1
/* Define if you have the getprotobynumber function. */
/* #undef HAVE_GETPROTOBYNUMBER */
diff --git a/configure.ac b/configure.ac
index 47dc117c36..dad56e06c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2128,9 +2128,9 @@ AC_SUBST(randpkt_man)
AC_SUBST(wiresharkfilter_man)
-dnl Checks for "gethostbyname()" - and "-lnsl", if we need it to get
-dnl "gethostbyname()".
-AC_WIRESHARK_GETHOSTBY_LIB_CHECK
+dnl Checks for "getaddrinfo()" - and "-lnsl", if we need it to get
+dnl "getaddrinfo()".
+AC_WIRESHARK_GETADDRINFO_LIB_CHECK
dnl Checks for "connect()", used as a proxy for "socket()" - and
dnl "-lsocket", if we need it to get "connect()".
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index c928bed707..2d4b3f1878 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -3185,7 +3185,7 @@ get_host_ipaddr(const char *host, guint32 *addrp)
fd_set rfds, wfds;
async_hostent_t ahe;
#else /* HAVE_C_ARES */
- struct hostent *hp;
+ struct addrinfo hint, *result = NULL;
#endif /* HAVE_C_ARES */
/*
@@ -3234,16 +3234,23 @@ get_host_ipaddr(const char *host, guint32 *addrp)
}
return FALSE;
#else /* ! HAVE_C_ARES */
- hp = gethostbyname(host);
- if (hp == NULL) {
- /* No. */
- return FALSE;
- /* Apparently, some versions of gethostbyaddr can
- * return IPv6 addresses. */
- } else if (hp->h_length <= (int) sizeof (struct in_addr)) {
- memcpy(&ipaddr, hp->h_addr, hp->h_length);
- } else {
- return FALSE;
+ /*
+ * This can be slow, particularly for capture files with lots of
+ * addresses. Should we just return FALSE instead?
+ */
+ memset(&hint, 0, sizeof(hint));
+ hint.ai_family = AF_INET;
+ if (getaddrinfo(host, NULL, &hint, &result) == 0) {
+ /* Probably more checks than necessary */
+ if (result != NULL) {
+ gboolean ret_val = FALSE;
+ if (result->ai_family == AF_INET && result->ai_addrlen == 4) {
+ memcpy(&ipaddr, result->ai_addr->sa_data, result->ai_addrlen);
+ ret_val = TRUE;
+ }
+ freeaddrinfo(result);
+ return ret_val;
+ }
}
#endif /* HAVE_C_ARES */
} else {
@@ -3274,8 +3281,8 @@ get_host_ipaddr6(const char *host, struct e_in6_addr *addrp)
int nfds;
fd_set rfds, wfds;
async_hostent_t ahe;
-#elif defined(HAVE_GETHOSTBYNAME2)
- struct hostent *hp;
+#elif defined(HAVE_GETADDRINFO)
+ struct addrinfo hint, *result = NULL;
#endif /* HAVE_C_ARES */
if (str_to_ip6(host, addrp))
@@ -3319,11 +3326,24 @@ get_host_ipaddr6(const char *host, struct e_in6_addr *addrp)
if (ahe.addr_size == ahe.copied) {
return TRUE;
}
-#elif defined(HAVE_GETHOSTBYNAME2)
- hp = gethostbyname2(host, AF_INET6);
- if (hp != NULL && hp->h_length == sizeof(struct e_in6_addr)) {
- memcpy(addrp, hp->h_addr, hp->h_length);
- return TRUE;
+#elif defined(HAVE_GETADDRINFO)
+ /*
+ * This can be slow, particularly for capture files with lots of
+ * addresses. Should we just return FALSE instead?
+ */
+ memset(&hint, 0, sizeof(hint));
+ hint.ai_family = AF_INET6;
+ if (getaddrinfo(host, NULL, &hint, &result) == 0) {
+ /* Probably more checks than necessary */
+ if (result != NULL) {
+ gboolean ret_val = FALSE;
+ if (result->ai_family == AF_INET6 && result->ai_addrlen == sizeof(struct e_in6_addr)) {
+ memcpy(addrp, result->ai_addr->sa_data, result->ai_addrlen);
+ ret_val = TRUE;
+ }
+ freeaddrinfo(result);
+ return ret_val;
+ }
}
#endif
@@ -3336,17 +3356,24 @@ get_host_ipaddr6(const char *host, struct e_in6_addr *addrp)
* that we don't know)
*/
const char* host_ip_af(const char *host
-#ifndef HAVE_GETHOSTBYNAME2
+#ifndef HAVE_GETADDRINFO
_U_
#endif
)
{
-#ifdef HAVE_GETHOSTBYNAME2
- struct hostent *h;
- return (h = gethostbyname2(host, AF_INET6)) && h->h_addrtype == AF_INET6 ? "ip6" : "ip";
-#else
- return "ip";
+ const char *af = "ip";
+#ifdef HAVE_GETADDRINFO
+ struct addrinfo hint, *result = NULL;
+ memset(&hint, 0, sizeof(hint));
+ hint.ai_family = AF_UNSPEC;
+ if (getaddrinfo(host, NULL, &hint, &result) == 0) {
+ if (result->ai_family == AF_INET6) {
+ af = "ip6";
+ }
+ freeaddrinfo(result);
+ }
#endif
+ return af;
}
GHashTable *
diff --git a/epan/dissectors/packet-kerberos.c b/epan/dissectors/packet-kerberos.c
index 4d06d5f421..4ede65f03b 100644
--- a/epan/dissectors/packet-kerberos.c
+++ b/epan/dissectors/packet-kerberos.c
@@ -512,6 +512,7 @@ read_keytab_file_from_preferences(void)
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
#ifdef _WIN32
/* prevent redefinition warnings in kfw-2.5\inc\win_mac.h */
+#undef HAVE_GETADDRINFO
#undef HAVE_STDARG_H
#undef HAVE_STDLIB_H
#undef HAVE_STRING_H
@@ -4244,7 +4245,7 @@ dissect_kerberos_ChangePasswdData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_,
/*--- End of included file: packet-kerberos-fn.c ---*/
-#line 1984 "../../asn1/kerberos/packet-kerberos-template.c"
+#line 1985 "../../asn1/kerberos/packet-kerberos-template.c"
/* Make wrappers around exported functions for now */
int
@@ -5282,7 +5283,7 @@ void proto_register_kerberos(void) {
NULL, HFILL }},
/*--- End of included file: packet-kerberos-hfarr.c ---*/
-#line 2365 "../../asn1/kerberos/packet-kerberos-template.c"
+#line 2366 "../../asn1/kerberos/packet-kerberos-template.c"
};
/* List of subtrees */
@@ -5356,7 +5357,7 @@ void proto_register_kerberos(void) {
&ett_kerberos_ChangePasswdData,
/*--- End of included file: packet-kerberos-ettarr.c ---*/
-#line 2381 "../../asn1/kerberos/packet-kerberos-template.c"
+#line 2382 "../../asn1/kerberos/packet-kerberos-template.c"
};
static ei_register_info ei[] = {
diff --git a/epan/dissectors/packet-kerberos.h b/epan/dissectors/packet-kerberos.h
index 2d08e0a7b0..c416952141 100644
--- a/epan/dissectors/packet-kerberos.h
+++ b/epan/dissectors/packet-kerberos.h
@@ -68,7 +68,7 @@ int dissect_krb5_cname(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *
int dissect_krb5_realm(proto_tree *tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_);
guint32 kerberos_output_keytype(void);
-guint get_krb_pdu_len(packet_info *, tvbuff_t *tvb, int offset, void *data);
+guint get_krb_pdu_len(packet_info *, tvbuff_t *tvb, int offset, void *data _U_);
gint kerberos_rm_to_reclen(guint krb_rm);