diff options
Diffstat (limited to 'lib/lwres')
-rw-r--r-- | lib/lwres/api | 2 | ||||
-rw-r--r-- | lib/lwres/context.c | 32 | ||||
-rw-r--r-- | lib/lwres/getaddrinfo.c | 18 | ||||
-rw-r--r-- | lib/lwres/gethost.c | 158 | ||||
-rw-r--r-- | lib/lwres/getipnode.c | 70 | ||||
-rw-r--r-- | lib/lwres/getrrset.c | 10 | ||||
-rw-r--r-- | lib/lwres/herror.c | 8 | ||||
-rw-r--r-- | lib/lwres/lwbuffer.c | 38 | ||||
-rw-r--r-- | lib/lwres/lwconfig.c | 8 | ||||
-rw-r--r-- | lib/lwres/lwinetaton.c | 11 | ||||
-rw-r--r-- | lib/lwres/lwinetpton.c | 11 | ||||
-rw-r--r-- | lib/lwres/lwres_gabn.c | 38 | ||||
-rw-r--r-- | lib/lwres/lwres_gnba.c | 42 | ||||
-rw-r--r-- | lib/lwres/lwres_grbn.c | 10 | ||||
-rw-r--r-- | lib/lwres/lwres_noop.c | 38 | ||||
-rw-r--r-- | lib/lwres/lwresutil.c | 46 | ||||
-rw-r--r-- | lib/lwres/strtoul.c | 8 |
17 files changed, 275 insertions, 273 deletions
diff --git a/lib/lwres/api b/lib/lwres/api index 2a5c388460ce6..0e65c9f9b1d4e 100644 --- a/lib/lwres/api +++ b/lib/lwres/api @@ -5,5 +5,5 @@ # 9.9: 90-109 # 9.9-sub: 130-139 LIBINTERFACE = 80 -LIBREVISION = 6 +LIBREVISION = 9 LIBAGE = 0 diff --git a/lib/lwres/context.c b/lib/lwres/context.c index 047707ffde46f..0dc5199b03e33 100644 --- a/lib/lwres/context.c +++ b/lib/lwres/context.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007-2009, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007-2009, 2012-2014 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -181,7 +181,11 @@ lwres_context_create(lwres_context_t **contextp, void *arg, ctx->sock = -1; ctx->timeout = LWRES_DEFAULT_TIMEOUT; +#ifndef WIN32 ctx->serial = time(NULL); /* XXXMLG or BEW */ +#else + ctx->serial = _time32(NULL); +#endif ctx->use_ipv4 = 1; ctx->use_ipv6 = 1; @@ -286,7 +290,11 @@ lwres_free(void *arg, void *mem, size_t len) { static lwres_result_t context_connect(lwres_context_t *ctx) { +#ifndef WIN32 int s; +#else + SOCKET s; +#endif int ret; struct sockaddr_in sin; struct sockaddr_in6 sin6; @@ -295,8 +303,8 @@ context_connect(lwres_context_t *ctx) { int domain; if (ctx->confdata.lwnext != 0) { - memcpy(&ctx->address, &ctx->confdata.lwservers[0], - sizeof(lwres_addr_t)); + memmove(&ctx->address, &ctx->confdata.lwservers[0], + sizeof(lwres_addr_t)); LWRES_LINK_INIT(&ctx->address, link); } else { /* The default is the IPv4 loopback address 127.0.0.1. */ @@ -310,16 +318,16 @@ context_connect(lwres_context_t *ctx) { } if (ctx->address.family == LWRES_ADDRTYPE_V4) { - memcpy(&sin.sin_addr, ctx->address.address, - sizeof(sin.sin_addr)); + memmove(&sin.sin_addr, ctx->address.address, + sizeof(sin.sin_addr)); sin.sin_port = htons(lwres_udp_port); sin.sin_family = AF_INET; sa = (struct sockaddr *)&sin; salen = sizeof(sin); domain = PF_INET; } else if (ctx->address.family == LWRES_ADDRTYPE_V6) { - memcpy(&sin6.sin6_addr, ctx->address.address, - sizeof(sin6.sin6_addr)); + memmove(&sin6.sin6_addr, ctx->address.address, + sizeof(sin6.sin6_addr)); sin6.sin6_port = htons(lwres_udp_port); sin6.sin6_family = AF_INET6; sa = (struct sockaddr *)&sin6; @@ -332,12 +340,16 @@ context_connect(lwres_context_t *ctx) { InitSockets(); #endif s = socket(domain, SOCK_DGRAM, IPPROTO_UDP); +#ifndef WIN32 if (s < 0) { -#ifdef WIN32 + return (LWRES_R_IOERROR); + } +#else + if (s == INVALID_SOCKET) { DestroySockets(); -#endif return (LWRES_R_IOERROR); } +#endif ret = connect(s, sa, salen); if (ret != 0) { @@ -357,7 +369,7 @@ context_connect(lwres_context_t *ctx) { return (LWRES_R_IOERROR); } - ctx->sock = s; + ctx->sock = (int)s; return (LWRES_R_SUCCESS); } diff --git a/lib/lwres/getaddrinfo.c b/lib/lwres/getaddrinfo.c index 7d5f2fb04c476..1ebafd85a6788 100644 --- a/lib/lwres/getaddrinfo.c +++ b/lib/lwres/getaddrinfo.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2008, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * * This code is derived from software contributed to ISC by @@ -392,7 +392,7 @@ lwres_getaddrinfo(const char *hostname, const char *servname, * Convert to a V4 mapped address. */ struct in6_addr *a6 = (struct in6_addr *)abuf; - memcpy(&a6->s6_addr[12], &a6->s6_addr[0], 4); + memmove(&a6->s6_addr[12], &a6->s6_addr[0], 4); memset(&a6->s6_addr[10], 0xff, 2); memset(&a6->s6_addr[0], 0, 10); goto inet6_addr; @@ -427,7 +427,7 @@ lwres_getaddrinfo(const char *hostname, const char *servname, ai_list = ai; ai->ai_socktype = socktype; SIN(ai->ai_addr)->sin_port = port; - memcpy((char *)ai->ai_addr + addroff, abuf, addrsize); + memmove((char *)ai->ai_addr + addroff, abuf, addrsize); if (flags & AI_CANONNAME) { #if defined(LWRES_HAVE_SIN6_SCOPE_ID) if (ai->ai_family == AF_INET6) @@ -579,7 +579,7 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip, *aip = ai; ai->ai_socktype = socktype; SIN(ai->ai_addr)->sin_port = port; - memcpy(&SIN(ai->ai_addr)->sin_addr, v4_loop, 4); + memmove(&SIN(ai->ai_addr)->sin_addr, v4_loop, 4); } else { lwres = lwres_getaddrsbyname(lwrctx, hostname, LWRES_ADDRTYPE_V4, &by); @@ -597,8 +597,8 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip, *aip = ai; ai->ai_socktype = socktype; SIN(ai->ai_addr)->sin_port = port; - memcpy(&SIN(ai->ai_addr)->sin_addr, - addr->address, 4); + memmove(&SIN(ai->ai_addr)->sin_addr, + addr->address, 4); if (flags & AI_CANONNAME) { ai->ai_canonname = strdup(by->realname); if (ai->ai_canonname == NULL) @@ -643,7 +643,7 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, *aip = ai; ai->ai_socktype = socktype; SIN6(ai->ai_addr)->sin6_port = port; - memcpy(&SIN6(ai->ai_addr)->sin6_addr, v6_loop, 16); + memmove(&SIN6(ai->ai_addr)->sin6_addr, v6_loop, 16); } else { lwres = lwres_getaddrsbyname(lwrctx, hostname, LWRES_ADDRTYPE_V6, &by); @@ -661,8 +661,8 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, *aip = ai; ai->ai_socktype = socktype; SIN6(ai->ai_addr)->sin6_port = port; - memcpy(&SIN6(ai->ai_addr)->sin6_addr, - addr->address, 16); + memmove(&SIN6(ai->ai_addr)->sin6_addr, + addr->address, 16); if (flags & AI_CANONNAME) { ai->ai_canonname = strdup(by->realname); if (ai->ai_canonname == NULL) diff --git a/lib/lwres/gethost.c b/lib/lwres/gethost.c index 1a1efd4653057..e36fc188e5c36 100644 --- a/lib/lwres/gethost.c +++ b/lib/lwres/gethost.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2013, 2014 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -24,7 +24,7 @@ * lookups by means of the lightweight resolver. They are similar to the * standard gethostent(3) functions provided by most operating systems. * They use a struct hostent which is usually defined in <namedb.h>. - * + * * \code * struct hostent { * char *h_name; // official name of host @@ -35,36 +35,36 @@ * }; * #define h_addr h_addr_list[0] // address, for backward compatibility * \endcode - * + * * The members of this structure are: - * + * * \li h_name: * The official (canonical) name of the host. - * + * * \li h_aliases: * A NULL-terminated array of alternate names (nicknames) for the * host. - * + * * \li h_addrtype: * The type of address being returned -- PF_INET or PF_INET6. - * + * * \li h_length: * The length of the address in bytes. - * + * * \li h_addr_list: * A NULL terminated array of network addresses for the host. Host * addresses are returned in network byte order. - * + * * For backward compatibility with very old software, h_addr is the first * address in h_addr_list. - * + * * lwres_gethostent(), lwres_sethostent(), lwres_endhostent(), * lwres_gethostent_r(), lwres_sethostent_r() and lwres_endhostent_r() * provide iteration over the known host entries on systems that provide * such functionality through facilities like /etc/hosts or NIS. The * lightweight resolver does not currently implement these functions; it * only provides them as stub functions that always return failure. - * + * * lwres_gethostbyname() and lwres_gethostbyname2() look up the hostname * name. lwres_gethostbyname() always looks for an IPv4 address while * lwres_gethostbyname2() looks for an address of protocol family af: @@ -72,7 +72,7 @@ * Successful calls of the functions return a struct hostent for the name * that was looked up. NULL is returned if the lookups by * lwres_gethostbyname() or lwres_gethostbyname2() fail. - * + * * Reverse lookups of addresses are performed by lwres_gethostbyaddr(). * addr is an address of length len bytes and protocol family type -- * PF_INET or PF_INET6. lwres_gethostbyname_r() is a thread-safe function @@ -83,7 +83,7 @@ * h_addr_list elements of the struct hostent returned in resbuf. * Successful calls to lwres_gethostbyname_r() return resbuf, which is a * pointer to the struct hostent it created. - * + * * lwres_gethostbyaddr_r() is a thread-safe function that performs a * reverse lookup of address addr which is len bytes long and is of * protocol family type -- PF_INET or PF_INET6. If an error occurs, the @@ -95,35 +95,35 @@ * struct hostent returned in resbuf. Successful calls to * lwres_gethostbyaddr_r() return resbuf, which is a pointer to the * struct hostent it created. - * + * * \section gethost_return Return Values - * + * * The functions lwres_gethostbyname(), lwres_gethostbyname2(), * lwres_gethostbyaddr(), and lwres_gethostent() return NULL to indicate * an error. In this case the global variable lwres_h_errno will contain * one of the following error codes defined in \link netdb.h <lwres/netdb.h>:\endlink - * + * * \li #HOST_NOT_FOUND: * The host or address was not found. - * + * * \li #TRY_AGAIN: * A recoverable error occurred, e.g., a timeout. Retrying the * lookup may succeed. - * + * * \li #NO_RECOVERY: * A non-recoverable error occurred. - * + * * \li #NO_DATA: * The name exists, but has no address information associated with * it (or vice versa in the case of a reverse lookup). The code * NO_ADDRESS is accepted as a synonym for NO_DATA for backwards * compatibility. - * + * * lwres_hstrerror() translates these error codes to suitable error * messages. - * + * * lwres_gethostent() and lwres_gethostent_r() always return NULL. - * + * * Successful calls to lwres_gethostbyname_r() and * lwres_gethostbyaddr_r() return resbuf, a pointer to the struct hostent * that was initialised by these functions. They return NULL if the @@ -131,19 +131,19 @@ * names referenced by the h_name, h_aliases, and h_addr_list elements of * the struct hostent. If buf was too small, both lwres_gethostbyname_r() * and lwres_gethostbyaddr_r() set the global variable errno to ERANGE. - * + * * \section gethost_see See Also - * + * * gethostent(), \link getipnode.c getipnode\endlink, lwres_hstrerror() - * + * * \section gethost_bugs Bugs - * + * * lwres_gethostbyname(), lwres_gethostbyname2(), lwres_gethostbyaddr() * and lwres_endhostent() are not thread safe; they return pointers to * static data and provide error codes through a global variable. * Thread-safe versions for name and address lookup are provided by * lwres_gethostbyname_r(), and lwres_gethostbyaddr_r() respectively. - * + * * The resolver daemon does not currently support any non-DNS name * services such as /etc/hosts or NIS, consequently the above functions * don't, either. @@ -161,7 +161,7 @@ #define LWRES_ALIGNBYTES (sizeof(char *) - 1) #define LWRES_ALIGN(p) \ - (((unsigned long)(p) + LWRES_ALIGNBYTES) &~ LWRES_ALIGNBYTES) + (((uintptr_t)(p) + LWRES_ALIGNBYTES) &~ LWRES_ALIGNBYTES) static struct hostent *he = NULL; static int copytobuf(struct hostent *, struct hostent *, char *, int); @@ -294,69 +294,69 @@ lwres_endhostent_r(void) { static int copytobuf(struct hostent *he, struct hostent *hptr, char *buf, int buflen) { - char *cp; - char **ptr; - int i, n; - int nptr, len; + char *cp; + char **ptr; + int i, n; + int nptr, len; - /* + /* * Find out the amount of space required to store the answer. */ - nptr = 2; /* NULL ptrs */ - len = (char *)LWRES_ALIGN(buf) - buf; - for (i = 0; he->h_addr_list[i]; i++, nptr++) { - len += he->h_length; - } - for (i = 0; he->h_aliases[i]; i++, nptr++) { - len += strlen(he->h_aliases[i]) + 1; - } - len += strlen(he->h_name) + 1; - len += nptr * sizeof(char*); - - if (len > buflen) { - return (-1); - } - - /* + nptr = 2; /* NULL ptrs */ + len = (int)((char *)LWRES_ALIGN(buf) - buf); + for (i = 0; he->h_addr_list[i]; i++, nptr++) { + len += he->h_length; + } + for (i = 0; he->h_aliases[i]; i++, nptr++) { + len += strlen(he->h_aliases[i]) + 1; + } + len += strlen(he->h_name) + 1; + len += nptr * sizeof(char*); + + if (len > buflen) { + return (-1); + } + + /* * Copy address size and type. */ - hptr->h_addrtype = he->h_addrtype; - n = hptr->h_length = he->h_length; + hptr->h_addrtype = he->h_addrtype; + n = hptr->h_length = he->h_length; - ptr = (char **)LWRES_ALIGN(buf); - cp = (char *)LWRES_ALIGN(buf) + nptr * sizeof(char *); + ptr = (char **)LWRES_ALIGN(buf); + cp = (char *)LWRES_ALIGN(buf) + nptr * sizeof(char *); - /* + /* * Copy address list. */ - hptr->h_addr_list = ptr; - for (i = 0; he->h_addr_list[i]; i++, ptr++) { - memcpy(cp, he->h_addr_list[i], n); - hptr->h_addr_list[i] = cp; - cp += n; - } - hptr->h_addr_list[i] = NULL; - ptr++; - - /* + hptr->h_addr_list = ptr; + for (i = 0; he->h_addr_list[i]; i++, ptr++) { + memmove(cp, he->h_addr_list[i], n); + hptr->h_addr_list[i] = cp; + cp += n; + } + hptr->h_addr_list[i] = NULL; + ptr++; + + /* * Copy official name. */ - n = strlen(he->h_name) + 1; - strcpy(cp, he->h_name); - hptr->h_name = cp; - cp += n; + n = strlen(he->h_name) + 1; + strcpy(cp, he->h_name); + hptr->h_name = cp; + cp += n; - /* + /* * Copy aliases. */ - hptr->h_aliases = ptr; - for (i = 0; he->h_aliases[i]; i++) { - n = strlen(he->h_aliases[i]) + 1; - strcpy(cp, he->h_aliases[i]); - hptr->h_aliases[i] = cp; - cp += n; - } - hptr->h_aliases[i] = NULL; - - return (0); + hptr->h_aliases = ptr; + for (i = 0; he->h_aliases[i]; i++) { + n = strlen(he->h_aliases[i]) + 1; + strcpy(cp, he->h_aliases[i]); + hptr->h_aliases[i] = cp; + cp += n; + } + hptr->h_aliases[i] = NULL; + + return (0); } diff --git a/lib/lwres/getipnode.c b/lib/lwres/getipnode.c index 300376ef139b2..85c396dfdfc28 100644 --- a/lib/lwres/getipnode.c +++ b/lib/lwres/getipnode.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -420,7 +420,7 @@ lwres_getipnodebyaddr(const void *src, size_t len, int af, int *error_num) { /* * Restore original address. */ - memcpy(he2->h_addr, src, len); + memmove(he2->h_addr, src, len); return (he2); } @@ -595,7 +595,7 @@ scan_interfaces6(int *have_v4, int *have_v6) { for (cp = buf; (*have_v4 == 0 || *have_v6 == 0) && cp < cplim; cp += cpsize) { - memcpy(&lifreq, cp, sizeof(lifreq)); + memmove(&lifreq, cp, sizeof(lifreq)); #ifdef LWRES_PLATFORM_HAVESALEN #ifdef FIX_ZERO_SA_LEN if (lifreq.lifr_addr.sa_len == 0) @@ -620,10 +620,10 @@ scan_interfaces6(int *have_v4, int *have_v6) { switch (lifreq.lifr_addr.ss_family) { case AF_INET: if (*have_v4 == 0) { - memcpy(&in4, - &((struct sockaddr_in *) - &lifreq.lifr_addr)->sin_addr, - sizeof(in4)); + memmove(&in4, + &((struct sockaddr_in *) + &lifreq.lifr_addr)->sin_addr, + sizeof(in4)); if (in4.s_addr == INADDR_ANY) break; n = ioctl(s, SIOCGLIFFLAGS, (char *)&lifreq); @@ -636,10 +636,10 @@ scan_interfaces6(int *have_v4, int *have_v6) { break; case AF_INET6: if (*have_v6 == 0) { - memcpy(&in6, - &((struct sockaddr_in6 *) - &lifreq.lifr_addr)->sin6_addr, - sizeof(in6)); + memmove(&in6, + &((struct sockaddr_in6 *) + &lifreq.lifr_addr)->sin6_addr, + sizeof(in6)); if (memcmp(&in6, &in6addr_any, sizeof(in6)) == 0) break; @@ -760,7 +760,7 @@ scan_interfaces(int *have_v4, int *have_v6) { for (cp = buf; (*have_v4 == 0 || *have_v6 == 0) && cp < cplim; cp += cpsize) { - memcpy(&u.ifreq, cp, sizeof(u.ifreq)); + memmove(&u.ifreq, cp, sizeof(u.ifreq)); #ifdef LWRES_PLATFORM_HAVESALEN #ifdef FIX_ZERO_SA_LEN if (u.ifreq.ifr_addr.sa_len == 0) @@ -775,7 +775,7 @@ scan_interfaces(int *have_v4, int *have_v6) { cpsize = sizeof(u.ifreq.ifr_name) + u.ifreq.ifr_addr.sa_len; #endif /* HAVE_MINIMUM_IFREQ */ if (cpsize > sizeof(u.ifreq) && cpsize <= sizeof(u)) - memcpy(&u.ifreq, cp, cpsize); + memmove(&u.ifreq, cp, cpsize); #elif defined SIOCGIFCONF_ADDR cpsize = sizeof(u.ifreq); #else @@ -787,10 +787,10 @@ scan_interfaces(int *have_v4, int *have_v6) { switch (u.ifreq.ifr_addr.sa_family) { case AF_INET: if (*have_v4 == 0) { - memcpy(&in4, - &((struct sockaddr_in *) - &u.ifreq.ifr_addr)->sin_addr, - sizeof(in4)); + memmove(&in4, + &((struct sockaddr_in *) + &u.ifreq.ifr_addr)->sin_addr, + sizeof(in4)); if (in4.s_addr == INADDR_ANY) break; n = ioctl(s, SIOCGIFFLAGS, (char *)&u.ifreq); @@ -803,10 +803,10 @@ scan_interfaces(int *have_v4, int *have_v6) { break; case AF_INET6: if (*have_v6 == 0) { - memcpy(&in6, - &((struct sockaddr_in6 *) - &u.ifreq.ifr_addr)->sin6_addr, - sizeof(in6)); + memmove(&in6, + &((struct sockaddr_in6 *) + &u.ifreq.ifr_addr)->sin6_addr, + sizeof(in6)); if (memcmp(&in6, &in6addr_any, sizeof(in6)) == 0) break; @@ -908,13 +908,13 @@ copyandmerge(struct hostent *he1, struct hostent *he2, int af, int *error_num) * Convert to mapped if required. */ if (af == AF_INET6 && he1->h_addrtype == AF_INET) { - memcpy(*npp, in6addr_mapped, - sizeof(in6addr_mapped)); - memcpy(*npp + sizeof(in6addr_mapped), *cpp, - INADDRSZ); + memmove(*npp, in6addr_mapped, + sizeof(in6addr_mapped)); + memmove(*npp + sizeof(in6addr_mapped), *cpp, + INADDRSZ); } else { - memcpy(*npp, *cpp, - (af == AF_INET) ? INADDRSZ : IN6ADDRSZ); + memmove(*npp, *cpp, + (af == AF_INET) ? INADDRSZ : IN6ADDRSZ); } cpp++; npp++; @@ -931,13 +931,13 @@ copyandmerge(struct hostent *he1, struct hostent *he2, int af, int *error_num) * Convert to mapped if required. */ if (af == AF_INET6 && he2->h_addrtype == AF_INET) { - memcpy(*npp, in6addr_mapped, - sizeof(in6addr_mapped)); - memcpy(*npp + sizeof(in6addr_mapped), *cpp, - INADDRSZ); + memmove(*npp, in6addr_mapped, + sizeof(in6addr_mapped)); + memmove(*npp + sizeof(in6addr_mapped), *cpp, + INADDRSZ); } else { - memcpy(*npp, *cpp, - (af == AF_INET) ? INADDRSZ : IN6ADDRSZ); + memmove(*npp, *cpp, + (af == AF_INET) ? INADDRSZ : IN6ADDRSZ); } cpp++; npp++; @@ -1060,7 +1060,7 @@ hostfromaddr(lwres_gnbaresponse_t *addr, int af, const void *src) { he->h_addr_list[0] = malloc(he->h_length); if (he->h_addr_list[0] == NULL) goto cleanup; - memcpy(he->h_addr_list[0], src, he->h_length); + memmove(he->h_addr_list[0], src, he->h_length); he->h_addr_list[1] = NULL; return (he); @@ -1140,7 +1140,7 @@ hostfromname(lwres_gabnresponse_t *name, int af) { he->h_addr_list[i] = malloc(he->h_length); if (he->h_addr_list[i] == NULL) goto cleanup; - memcpy(he->h_addr_list[i], addr->address, he->h_length); + memmove(he->h_addr_list[i], addr->address, he->h_length); addr = LWRES_LIST_NEXT(addr, link); i++; } diff --git a/lib/lwres/getrrset.c b/lib/lwres/getrrset.c index 16af741d2e43b..cd37abcd0bead 100644 --- a/lib/lwres/getrrset.c +++ b/lib/lwres/getrrset.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -228,8 +228,8 @@ lwres_getrrsetbyname(const char *hostname, unsigned int rdclass, result = ERRSET_NOMEMORY; goto fail; } - memcpy(rrset->rri_rdatas[i].rdi_data, response->rdatas[i], - rrset->rri_rdatas[i].rdi_length); + memmove(rrset->rri_rdatas[i].rdi_data, response->rdatas[i], + rrset->rri_rdatas[i].rdi_length); } rrset->rri_nsigs = response->nsigs; rrset->rri_sigs = sane_calloc(rrset->rri_nsigs, @@ -246,8 +246,8 @@ lwres_getrrsetbyname(const char *hostname, unsigned int rdclass, result = ERRSET_NOMEMORY; goto fail; } - memcpy(rrset->rri_sigs[i].rdi_data, response->sigs[i], - rrset->rri_sigs[i].rdi_length); + memmove(rrset->rri_sigs[i].rdi_data, response->sigs[i], + rrset->rri_sigs[i].rdi_length); } lwres_grbnresponse_free(lwrctx, &response); diff --git a/lib/lwres/herror.c b/lib/lwres/herror.c index 49de797e42f6b..0fe6097d07c1e 100644 --- a/lib/lwres/herror.c +++ b/lib/lwres/herror.c @@ -1,5 +1,5 @@ /* - * Portions Copyright (C) 2004, 2005, 2007, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 2004, 2005, 2007, 2011, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 2000, 2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -27,11 +27,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * diff --git a/lib/lwres/lwbuffer.c b/lib/lwres/lwbuffer.c index 49aaeb7bc912d..787bc3c9f5e25 100644 --- a/lib/lwres/lwbuffer.c +++ b/lib/lwres/lwbuffer.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -23,7 +23,7 @@ * These functions provide bounds checked access to a region of memory * where data is being read or written. They are based on, and similar * to, the isc_buffer_ functions in the ISC library. - * + * * A buffer is a region of memory, together with a set of related * subregions. The used region and the available region are disjoint, and * their union is the buffer's region. The used region extends from the @@ -31,7 +31,7 @@ * region extends from one byte greater than the last used byte to the * end of the buffer's region. The size of the used region can be changed * using various buffer commands. Initially, the used region is empty. - * + * * The used region is further subdivided into two disjoint regions: the * consumed region and the remaining region. The union of these two * regions is the used region. The consumed region extends from the @@ -39,14 +39,14 @@ * any). The remaining region the current pointer to the end of the used * region. The size of the consumed region can be changed using various * buffer commands. Initially, the consumed region is empty. - * + * * The active region is an (optional) subregion of the remaining region. * It extends from the current offset to an offset in the remaining * region. Initially, the active region is empty. If the current offset * advances beyond the chosen offset, the active region will also be * empty. - * - * + * + * * \verbatim * /------------entire length---------------\\ * /----- used region -----\\/-- available --\\ @@ -54,54 +54,54 @@ * | consumed | remaining | | * +----------------------------------------+ * a b c d e - * + * * a == base of buffer. * b == current pointer. Can be anywhere between a and d. * c == active pointer. Meaningful between b and d. * d == used pointer. * e == length of buffer. - * + * * a-e == entire length of buffer. * a-d == used region. * a-b == consumed region. * b-d == remaining region. * b-c == optional active region. * \endverbatim - * + * * lwres_buffer_init() initializes the lwres_buffer_t *b and assocates it * with the memory region of size length bytes starting at location base. - * + * * lwres_buffer_invalidate() marks the buffer *b as invalid. Invalidating * a buffer after use is not required, but makes it possible to catch its * possible accidental use. - * + * * The functions lwres_buffer_add() and lwres_buffer_subtract() * respectively increase and decrease the used space in buffer *b by n * bytes. lwres_buffer_add() checks for buffer overflow and * lwres_buffer_subtract() checks for underflow. These functions do not * allocate or deallocate memory. They just change the value of used. - * + * * A buffer is re-initialised by lwres_buffer_clear(). The function sets * used , current and active to zero. - * + * * lwres_buffer_first() makes the consumed region of buffer *p empty by * setting current to zero (the start of the buffer). - * + * * lwres_buffer_forward() increases the consumed region of buffer *b by n * bytes, checking for overflow. Similarly, lwres_buffer_back() decreases * buffer b's consumed region by n bytes and checks for underflow. - * + * * lwres_buffer_getuint8() reads an unsigned 8-bit integer from *b and * returns it. lwres_buffer_putuint8() writes the unsigned 8-bit integer * val to buffer *b. - * + * * lwres_buffer_getuint16() and lwres_buffer_getuint32() are identical to * lwres_buffer_putuint8() except that they respectively read an unsigned * 16-bit or 32-bit integer in network byte order from b. Similarly, * lwres_buffer_putuint16() and lwres_buffer_putuint32() writes the * unsigned 16-bit or 32-bit integer val to buffer b, in network byte * order. - * + * * Arbitrary amounts of data are read or written from a lightweight * resolver buffer with lwres_buffer_getmem() and lwres_buffer_putmem() * respectively. lwres_buffer_putmem() copies length bytes of memory at @@ -339,7 +339,7 @@ lwres_buffer_putmem(lwres_buffer_t *b, const unsigned char *base, REQUIRE(b->used + length <= b->length); cp = (unsigned char *)b->base + b->used; - memcpy(cp, base, length); + memmove(cp, base, length); b->used += length; } @@ -357,5 +357,5 @@ lwres_buffer_getmem(lwres_buffer_t *b, unsigned char *base, cp += b->current; b->current += length; - memcpy(base, cp, length); + memmove(base, cp, length); } diff --git a/lib/lwres/lwconfig.c b/lib/lwres/lwconfig.c index e9a867100f290..62630238e1211 100644 --- a/lib/lwres/lwconfig.c +++ b/lib/lwres/lwconfig.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2008, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008, 2011, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -455,16 +455,16 @@ lwres_create_addr(const char *buffer, lwres_addr_t *addr, int convert_zero) { unsigned char zeroaddress[] = {0, 0, 0, 0}; unsigned char loopaddress[] = {127, 0, 0, 1}; if (memcmp(&v4, zeroaddress, 4) == 0) - memcpy(&v4, loopaddress, 4); + memmove(&v4, loopaddress, 4); } addr->family = LWRES_ADDRTYPE_V4; addr->length = NS_INADDRSZ; - memcpy((void *)addr->address, &v4, NS_INADDRSZ); + memmove((void *)addr->address, &v4, NS_INADDRSZ); } else if (lwres_net_pton(AF_INET6, buffer, &v6) == 1) { addr->family = LWRES_ADDRTYPE_V6; addr->length = NS_IN6ADDRSZ; - memcpy((void *)addr->address, &v6, NS_IN6ADDRSZ); + memmove((void *)addr->address, &v6, NS_IN6ADDRSZ); } else { return (LWRES_R_FAILURE); /* Unrecognised format. */ } diff --git a/lib/lwres/lwinetaton.c b/lib/lwres/lwinetaton.c index 5a0d85a365d64..8c7ca7cccf3c3 100644 --- a/lib/lwres/lwinetaton.c +++ b/lib/lwres/lwinetaton.c @@ -1,5 +1,5 @@ /* - * Portions Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 2004, 2005, 2007, 2012-2014 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 1996-2001, 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -27,11 +27,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -96,7 +92,8 @@ static char rcsid[] = "$Id: lwinetaton.c,v 1.16 2007/06/19 23:47:22 tbox Exp $"; int lwres_net_aton(const char *cp, struct in_addr *addr) { lwres_uint32_t val; - int base, n; + int base; + ptrdiff_t n; unsigned char c; lwres_uint8_t parts[4]; lwres_uint8_t *pp = parts; diff --git a/lib/lwres/lwinetpton.c b/lib/lwres/lwinetpton.c index e0ea85df35736..efeb21b70e80d 100644 --- a/lib/lwres/lwinetpton.c +++ b/lib/lwres/lwinetpton.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2011, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2011-2014 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1996-2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -90,8 +90,9 @@ inet_pton4(const char *src, unsigned char *dst) { const char *pch; if ((pch = strchr(digits, ch)) != NULL) { - unsigned int new = *tp * 10 + (pch - digits); + unsigned int new = *tp * 10; + new += (unsigned int)(pch - digits); if (new > 255) return (0); *tp = new; @@ -115,7 +116,7 @@ inet_pton4(const char *src, unsigned char *dst) { } if (octets < 4) return (0); - memcpy(dst, tmp, NS_INADDRSZ); + memmove(dst, tmp, NS_INADDRSZ); return (1); } @@ -198,7 +199,7 @@ inet_pton6(const char *src, unsigned char *dst) { * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. */ - const int n = tp - colonp; + const int n = (int)(tp - colonp); int i; for (i = 1; i <= n; i++) { @@ -209,6 +210,6 @@ inet_pton6(const char *src, unsigned char *dst) { } if (tp != endp) return (0); - memcpy(dst, tmp, NS_IN6ADDRSZ); + memmove(dst, tmp, NS_IN6ADDRSZ); return (1); } diff --git a/lib/lwres/lwres_gabn.c b/lib/lwres/lwres_gabn.c index 3363e66b89b4e..d770579cb4165 100644 --- a/lib/lwres/lwres_gabn.c +++ b/lib/lwres/lwres_gabn.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2013 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -40,23 +40,23 @@ typedef struct lwres_addr lwres_addr_t; typedef LWRES_LIST(lwres_addr_t) lwres_addrlist_t; typedef struct { - lwres_uint32_t flags; - lwres_uint32_t addrtypes; - lwres_uint16_t namelen; - char *name; + lwres_uint32_t flags; + lwres_uint32_t addrtypes; + lwres_uint16_t namelen; + char *name; } lwres_gabnrequest_t; typedef struct { - lwres_uint32_t flags; - lwres_uint16_t naliases; - lwres_uint16_t naddrs; - char *realname; - char **aliases; - lwres_uint16_t realnamelen; - lwres_uint16_t *aliaslen; - lwres_addrlist_t addrs; - void *base; - size_t baselen; + lwres_uint32_t flags; + lwres_uint16_t naliases; + lwres_uint16_t naddrs; + char *realname; + char **aliases; + lwres_uint16_t realnamelen; + lwres_uint16_t *aliaslen; + lwres_addrlist_t addrs; + void *base; + size_t baselen; } lwres_gabnresponse_t; \endcode @@ -142,9 +142,9 @@ lwres_gabnrequest_render(lwres_context_t *ctx, lwres_gabnrequest_t *req, if (buf == NULL) return (LWRES_R_NOMEMORY); - lwres_buffer_init(b, buf, buflen); + lwres_buffer_init(b, buf, (unsigned int)buflen); - pkt->length = buflen; + pkt->length = (lwres_uint32_t)buflen; pkt->version = LWRES_LWPACKETVERSION_0; pkt->pktflags &= ~LWRES_LWPACKETFLAG_RESPONSE; pkt->opcode = LWRES_OPCODE_GETADDRSBYNAME; @@ -223,9 +223,9 @@ lwres_gabnresponse_render(lwres_context_t *ctx, lwres_gabnresponse_t *req, buf = CTXMALLOC(buflen); if (buf == NULL) return (LWRES_R_NOMEMORY); - lwres_buffer_init(b, buf, buflen); + lwres_buffer_init(b, buf, (unsigned int)buflen); - pkt->length = buflen; + pkt->length = (lwres_uint32_t)buflen; pkt->version = LWRES_LWPACKETVERSION_0; pkt->pktflags |= LWRES_LWPACKETFLAG_RESPONSE; pkt->opcode = LWRES_OPCODE_GETADDRSBYNAME; diff --git a/lib/lwres/lwres_gnba.c b/lib/lwres/lwres_gnba.c index d18ae153f23e0..43d8ac53e2455 100644 --- a/lib/lwres/lwres_gnba.c +++ b/lib/lwres/lwres_gnba.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2013 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -29,7 +29,7 @@ structure. Another render function converts the getnamebyaddr response structure -- lwres_gnbaresponse_t to the canonical format. This is complemented by a parse function which converts a packet in - canonical format to a getnamebyaddr response structure. + canonical format to a getnamebyaddr response structure. These structures are defined in \link lwres.h <lwres/lwres.h.>\endlink They are shown below. @@ -38,19 +38,19 @@ #define LWRES_OPCODE_GETNAMEBYADDR 0x00010002U typedef struct { - lwres_uint32_t flags; - lwres_addr_t addr; + lwres_uint32_t flags; + lwres_addr_t addr; } lwres_gnbarequest_t; typedef struct { - lwres_uint32_t flags; - lwres_uint16_t naliases; - char *realname; - char **aliases; - lwres_uint16_t realnamelen; - lwres_uint16_t *aliaslen; - void *base; - size_t baselen; + lwres_uint32_t flags; + lwres_uint16_t naliases; + char *realname; + char **aliases; + lwres_uint16_t realnamelen; + lwres_uint16_t *aliaslen; + void *base; + size_t baselen; } lwres_gnbaresponse_t; \endcode @@ -66,14 +66,14 @@ typedef struct { of packet pkt to a lwres_gnbarequest_t structure. Buffer b provides space to be used for storing this structure. When the function succeeds, the resulting lwres_gnbarequest_t is made available - through *structp. lwres_gnbaresponse_parse() offers the same -semantics as lwres_gnbarequest_parse() except it yields a + through *structp. lwres_gnbaresponse_parse() offers the same +semantics as lwres_gnbarequest_parse() except it yields a lwres_gnbaresponse_t structure. lwres_gnbaresponse_free() and lwres_gnbarequest_free() release the - memory in resolver context ctx that was allocated to the - lwres_gnbaresponse_t or lwres_gnbarequest_t structures referenced - via structp. Any memory associated with ancillary buffers and + memory in resolver context ctx that was allocated to the + lwres_gnbaresponse_t or lwres_gnbarequest_t structures referenced + via structp. Any memory associated with ancillary buffers and strings for those structures is also discarded. \section lwres_gbna_return Return Values @@ -135,9 +135,9 @@ lwres_gnbarequest_render(lwres_context_t *ctx, lwres_gnbarequest_t *req, buf = CTXMALLOC(buflen); if (buf == NULL) return (LWRES_R_NOMEMORY); - lwres_buffer_init(b, buf, buflen); + lwres_buffer_init(b, buf, (unsigned int)buflen); - pkt->length = buflen; + pkt->length = (lwres_uint32_t)buflen; pkt->version = LWRES_LWPACKETVERSION_0; pkt->pktflags &= ~LWRES_LWPACKETFLAG_RESPONSE; pkt->opcode = LWRES_OPCODE_GETNAMEBYADDR; @@ -199,9 +199,9 @@ lwres_gnbaresponse_render(lwres_context_t *ctx, lwres_gnbaresponse_t *req, buf = CTXMALLOC(buflen); if (buf == NULL) return (LWRES_R_NOMEMORY); - lwres_buffer_init(b, buf, buflen); + lwres_buffer_init(b, buf, (unsigned int)buflen); - pkt->length = buflen; + pkt->length = (lwres_uint32_t)buflen; pkt->version = LWRES_LWPACKETVERSION_0; pkt->pktflags |= LWRES_LWPACKETFLAG_RESPONSE; pkt->opcode = LWRES_OPCODE_GETNAMEBYADDR; diff --git a/lib/lwres/lwres_grbn.c b/lib/lwres/lwres_grbn.c index 72718bad0c5d0..a8ff2342bd7e5 100644 --- a/lib/lwres/lwres_grbn.c +++ b/lib/lwres/lwres_grbn.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2013 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -61,9 +61,9 @@ lwres_grbnrequest_render(lwres_context_t *ctx, lwres_grbnrequest_t *req, if (buf == NULL) return (LWRES_R_NOMEMORY); - lwres_buffer_init(b, buf, buflen); + lwres_buffer_init(b, buf, (unsigned int)buflen); - pkt->length = buflen; + pkt->length = (lwres_uint32_t)buflen; pkt->version = LWRES_LWPACKETVERSION_0; pkt->pktflags &= ~LWRES_LWPACKETFLAG_RESPONSE; pkt->opcode = LWRES_OPCODE_GETRDATABYNAME; @@ -139,9 +139,9 @@ lwres_grbnresponse_render(lwres_context_t *ctx, lwres_grbnresponse_t *req, buf = CTXMALLOC(buflen); if (buf == NULL) return (LWRES_R_NOMEMORY); - lwres_buffer_init(b, buf, buflen); + lwres_buffer_init(b, buf, (unsigned int)buflen); - pkt->length = buflen; + pkt->length = (lwres_uint32_t)buflen; pkt->version = LWRES_LWPACKETVERSION_0; pkt->pktflags |= LWRES_LWPACKETFLAG_RESPONSE; pkt->opcode = LWRES_OPCODE_GETRDATABYNAME; diff --git a/lib/lwres/lwres_noop.c b/lib/lwres/lwres_noop.c index 369fe4e18f715..10b40ee950a4f 100644 --- a/lib/lwres/lwres_noop.c +++ b/lib/lwres/lwres_noop.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2013 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -22,11 +22,11 @@ /** * These are low-level routines for creating and parsing lightweight * resolver no-op request and response messages. - * + * * The no-op message is analogous to a ping packet: a packet is sent to * the resolver daemon and is simply echoed back. The opcode is intended * to allow a client to determine if the server is operational or not. - * + * * There are four main functions for the no-op opcode. One render * function converts a no-op request structure -- lwres_nooprequest_t -- * to the lighweight resolver's canonical format. It is complemented by a @@ -35,27 +35,27 @@ * response structure -- lwres_noopresponse_t to the canonical format. * This is complemented by a parse function which converts a packet in * canonical format to a no-op response structure. - * + * * These structures are defined in \link lwres.h <lwres/lwres.h.> \endlink They are shown below. - * + * * \code * #define LWRES_OPCODE_NOOP 0x00000000U - * + * * typedef struct { * lwres_uint16_t datalength; * unsigned char *data; * } lwres_nooprequest_t; - * + * * typedef struct { * lwres_uint16_t datalength; * unsigned char *data; * } lwres_noopresponse_t; * \endcode - * + * * Although the structures have different types, they are identical. This * is because the no-op opcode simply echos whatever data was sent: the * response is therefore identical to the request. - * + * * lwres_nooprequest_render() uses resolver context ctx to convert no-op * request structure req to canonical format. The packet header structure * pkt is initialised and transferred to buffer b. The contents of *req @@ -63,7 +63,7 @@ * lwres_noopresponse_render() performs the same task, except it converts * a no-op response structure lwres_noopresponse_t to the lightweight * resolver's canonical format. - * + * * lwres_nooprequest_parse() uses context ctx to convert the contents of * packet pkt to a lwres_nooprequest_t structure. Buffer b provides space * to be used for storing this structure. When the function succeeds, the @@ -71,14 +71,14 @@ * lwres_noopresponse_parse() offers the same semantics as * lwres_nooprequest_parse() except it yields a lwres_noopresponse_t * structure. - * + * * lwres_noopresponse_free() and lwres_nooprequest_free() release the * memory in resolver context ctx that was allocated to the * lwres_noopresponse_t or lwres_nooprequest_t structures referenced via * structp. - * + * * \section lwres_noop_return Return Values - * + * * The no-op opcode functions lwres_nooprequest_render(), * lwres_noopresponse_render() lwres_nooprequest_parse() and * lwres_noopresponse_parse() all return #LWRES_R_SUCCESS on success. They @@ -91,9 +91,9 @@ * received packet. These functions will return #LWRES_R_FAILURE if * pktflags in the packet header structure #lwres_lwpacket_t indicate that * the packet is not a response to an earlier query. - * + * * \section lwres_noop_see See Also - * + * * lwpacket.c */ @@ -132,9 +132,9 @@ lwres_nooprequest_render(lwres_context_t *ctx, lwres_nooprequest_t *req, buf = CTXMALLOC(buflen); if (buf == NULL) return (LWRES_R_NOMEMORY); - lwres_buffer_init(b, buf, buflen); + lwres_buffer_init(b, buf, (unsigned int)buflen); - pkt->length = buflen; + pkt->length = (lwres_uint32_t)buflen; pkt->version = LWRES_LWPACKETVERSION_0; pkt->pktflags &= ~LWRES_LWPACKETFLAG_RESPONSE; pkt->opcode = LWRES_OPCODE_NOOP; @@ -185,9 +185,9 @@ lwres_noopresponse_render(lwres_context_t *ctx, lwres_noopresponse_t *req, buf = CTXMALLOC(buflen); if (buf == NULL) return (LWRES_R_NOMEMORY); - lwres_buffer_init(b, buf, buflen); + lwres_buffer_init(b, buf, (unsigned int)buflen); - pkt->length = buflen; + pkt->length = (lwres_uint32_t)buflen; pkt->version = LWRES_LWPACKETVERSION_0; pkt->pktflags |= LWRES_LWPACKETFLAG_RESPONSE; pkt->opcode = LWRES_OPCODE_NOOP; diff --git a/lib/lwres/lwresutil.c b/lib/lwres/lwresutil.c index 3bf5660f3da5f..0d1e5aaf878c9 100644 --- a/lib/lwres/lwresutil.c +++ b/lib/lwres/lwresutil.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -27,7 +27,7 @@ * given by *len. The buffer's current pointer is advanced to point at * the character following the string length, the encoded string, and * the trailing NULL character. - * + * * lwres_addr_parse() extracts an address from the buffer b. The * buffer's current pointer b->current is presumed to point at an * encoded address: the address preceded by a 32-bit protocol family @@ -36,10 +36,10 @@ * the address that was copied. b->current is advanced to point at the * next byte of available data in the buffer following the encoded * address. - * + * * lwres_getaddrsbyname() and lwres_getnamebyaddr() use the * lwres_gnbaresponse_t structure defined below: - * + * * \code * typedef struct { * lwres_uint32_t flags; @@ -54,45 +54,45 @@ * size_t baselen; * } lwres_gabnresponse_t; * \endcode - * + * * The contents of this structure are not manipulated directly but - * they are controlled through the \link lwres_gabn.c lwres_gabn*\endlink functions. - * + * they are controlled through the \link lwres_gabn.c lwres_gabn*\endlink functions. + * * The lightweight resolver uses lwres_getaddrsbyname() to perform * foward lookups. Hostname name is looked up using the resolver - * context ctx for memory allocation. addrtypes is a bitmask + * context ctx for memory allocation. addrtypes is a bitmask * indicating which type of addresses are to be looked up. Current * values for this bitmask are #LWRES_ADDRTYPE_V4 for IPv4 addresses * and #LWRES_ADDRTYPE_V6 for IPv6 addresses. Results of the lookup are * returned in *structp. - * - * lwres_getnamebyaddr() performs reverse lookups. Resolver context + * + * lwres_getnamebyaddr() performs reverse lookups. Resolver context * ctx is used for memory allocation. The address type is indicated by * addrtype: #LWRES_ADDRTYPE_V4 or #LWRES_ADDRTYPE_V6. The address to be - * looked up is given by addr and its length is addrlen bytes. The - * result of the function call is made available through *structp. - * + * looked up is given by addr and its length is addrlen bytes. The + * result of the function call is made available through *structp. + * * \section lwresutil_return Return Values - * + * * Successful calls to lwres_string_parse() and lwres_addr_parse() - * return #LWRES_R_SUCCESS. Both functions return #LWRES_R_FAILURE if - * the buffer is corrupt or #LWRES_R_UNEXPECTEDEND if the buffer has + * return #LWRES_R_SUCCESS. Both functions return #LWRES_R_FAILURE if + * the buffer is corrupt or #LWRES_R_UNEXPECTEDEND if the buffer has * less space than expected for the components of the encoded string * or address. - * + * * lwres_getaddrsbyname() returns #LWRES_R_SUCCESS on success and it * returns #LWRES_R_NOTFOUND if the hostname name could not be found. - * + * * #LWRES_R_SUCCESS is returned by a successful call to * lwres_getnamebyaddr(). - * + * * Both lwres_getaddrsbyname() and lwres_getnamebyaddr() return * #LWRES_R_NOMEMORY when memory allocation requests fail and * #LWRES_R_UNEXPECTEDEND if the buffers used for sending queries and - * receiving replies are too small. - * + * receiving replies are too small. + * * \section lwresutil_see See Also - * + * * lwbuffer.c, lwres_gabn.c */ @@ -390,7 +390,7 @@ lwres_getnamebyaddr(lwres_context_t *ctx, lwres_uint32_t addrtype, request.flags = 0; request.addr.family = addrtype; request.addr.length = addrlen; - memcpy(request.addr.address, addr, addrlen); + memmove(request.addr.address, addr, addrlen); pkt.pktflags = 0; pkt.serial = serial; pkt.result = 0; diff --git a/lib/lwres/strtoul.c b/lib/lwres/strtoul.c index c9413a4663d50..f66f5a7937b51 100644 --- a/lib/lwres/strtoul.c +++ b/lib/lwres/strtoul.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -27,11 +27,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * |