summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ares__get_hostent.c7
-rw-r--r--ares_gethostbyname.c5
-rw-r--r--ares_nowarn.c50
-rw-r--r--ares_nowarn.h4
-rw-r--r--ares_parse_ptr_reply.c5
-rw-r--r--configure.ac3
6 files changed, 66 insertions, 8 deletions
diff --git a/ares__get_hostent.c b/ares__get_hostent.c
index 298df09..94428ee 100644
--- a/ares__get_hostent.c
+++ b/ares__get_hostent.c
@@ -1,5 +1,5 @@
-/* Copyright 1998, 2010 by the Massachusetts Institute of Technology.
+/* Copyright 1998, 2011 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -31,6 +31,7 @@
#include "ares.h"
#include "inet_net_pton.h"
+#include "ares_nowarn.h"
#include "ares_private.h"
int ares__get_hostent(FILE *fp, int family, struct hostent **host)
@@ -219,8 +220,8 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
break;
/* Copy actual network address family and length. */
- hostent->h_addrtype = addr.family;
- hostent->h_length = (int)addrlen;
+ hostent->h_addrtype = aresx_sitoss(addr.family);
+ hostent->h_length = aresx_uztoss(addrlen);
/* Free line buffer. */
free(line);
diff --git a/ares_gethostbyname.c b/ares_gethostbyname.c
index ad89dc2..4869402 100644
--- a/ares_gethostbyname.c
+++ b/ares_gethostbyname.c
@@ -1,5 +1,5 @@
-/* Copyright 1998 by the Massachusetts Institute of Technology.
+/* Copyright 1998, 2011 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -49,6 +49,7 @@
#include "inet_net_pton.h"
#include "bitncmp.h"
#include "ares_platform.h"
+#include "ares_nowarn.h"
#include "ares_private.h"
#ifdef WATT32
@@ -300,7 +301,7 @@ static int fake_hostent(const char *name, int family,
/* Fill in the rest of the host structure and terminate the query. */
addrs[1] = NULL;
hostent.h_aliases = aliases;
- hostent.h_addrtype = family;
+ hostent.h_addrtype = aresx_sitoss(family);
hostent.h_addr_list = addrs;
callback(arg, ARES_SUCCESS, 0, &hostent);
diff --git a/ares_nowarn.c b/ares_nowarn.c
index 701add5..6c92f6f 100644
--- a/ares_nowarn.c
+++ b/ares_nowarn.c
@@ -39,6 +39,19 @@
#include "ares_nowarn.h"
+#if (SIZEOF_SHORT == 2)
+# define CARES_MASK_SSHORT 0x7FFF
+# define CARES_MASK_USHORT 0xFFFF
+#elif (SIZEOF_SHORT == 4)
+# define CARES_MASK_SSHORT 0x7FFFFFFF
+# define CARES_MASK_USHORT 0xFFFFFFFF
+#elif (SIZEOF_SHORT == 8)
+# define CARES_MASK_SSHORT 0x7FFFFFFFFFFFFFFF
+# define CARES_MASK_USHORT 0xFFFFFFFFFFFFFFFF
+#else
+# error "SIZEOF_SHORT not defined"
+#endif
+
#if (SIZEOF_INT == 2)
# define CARES_MASK_SINT 0x7FFF
# define CARES_MASK_UINT 0xFFFF
@@ -72,6 +85,43 @@ int aresx_uztosi(size_t uznum)
}
/*
+** unsigned size_t to signed short
+*/
+
+short aresx_uztoss(size_t uznum)
+{
+#ifdef __INTEL_COMPILER
+# pragma warning(push)
+# pragma warning(disable:810) /* conversion may lose significant bits */
+#endif
+
+ return (short)(uznum & (size_t) CARES_MASK_SSHORT);
+
+#ifdef __INTEL_COMPILER
+# pragma warning(pop)
+#endif
+}
+
+/*
+** signed int to signed short
+*/
+
+short aresx_sitoss(int sinum)
+{
+#ifdef __INTEL_COMPILER
+# pragma warning(push)
+# pragma warning(disable:810) /* conversion may lose significant bits */
+#endif
+
+ DEBUGASSERT(sinum >= 0);
+ return (short)(sinum & (int) CARES_MASK_SSHORT);
+
+#ifdef __INTEL_COMPILER
+# pragma warning(pop)
+#endif
+}
+
+/*
** signed long to signed int
*/
diff --git a/ares_nowarn.h b/ares_nowarn.h
index bcaa227..af112b9 100644
--- a/ares_nowarn.h
+++ b/ares_nowarn.h
@@ -19,6 +19,10 @@
int aresx_uztosi(size_t uznum);
+short aresx_uztoss(size_t uznum);
+
+short aresx_sitoss(int sinum);
+
int aresx_sltosi(long slnum);
int aresx_sztosi(ssize_t sznum);
diff --git a/ares_parse_ptr_reply.c b/ares_parse_ptr_reply.c
index 3b6dbc3..ed4a405 100644
--- a/ares_parse_ptr_reply.c
+++ b/ares_parse_ptr_reply.c
@@ -42,6 +42,7 @@
#include <string.h>
#include "ares.h"
#include "ares_dns.h"
+#include "ares_nowarn.h"
#include "ares_private.h"
int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
@@ -189,8 +190,8 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
for (i=0 ; i<aliascnt ; i++)
hostent->h_aliases[i] = aliases[i];
hostent->h_aliases[aliascnt] = NULL;
- hostent->h_addrtype = family;
- hostent->h_length = addrlen;
+ hostent->h_addrtype = aresx_sitoss(family);
+ hostent->h_length = aresx_sitoss(addrlen);
memcpy(hostent->h_addr_list[0], addr, addrlen);
hostent->h_addr_list[1] = NULL;
*host = hostent;
diff --git a/configure.ac b/configure.ac
index d692c5b..ad6eef4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -460,8 +460,9 @@ AC_HEADER_TIME
CURL_CHECK_STRUCT_TIMEVAL
AC_CHECK_SIZEOF(size_t)
-AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(short)
CARES_CONFIGURE_LONG
AC_CHECK_SIZEOF(time_t)