1101. [bug] Array bounds read error in lwres_gai_strerror.
+1090. [bug] libbind: dns_ho.c:add_hostent() was not returning
+ the amount of memory consumed resulting in garbage
+ address being returned. Alignment calculations were
+ wasting space. We weren't suppressing duplicate
+ addresses.
+
1088. [port] libbind: MPE/iX C.70 (incomplete)
1086. [port] libbind: sunos: old sprintf.
/* BIND Id: gethnamaddr.c,v 8.15 1996/05/22 04:56:30 vixie Exp $ */
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: dns_ho.c,v 1.5 2001/07/02 00:44:50 marka Exp $";
+static const char rcsid[] = "$Id: dns_ho.c,v 1.5.2.1 2001/11/02 20:35:28 gson Exp $";
#endif /* LIBC_SCCS and not lint */
/* Imports. */
buflen -= nn;
}
/* Ensure alignment. */
- bp += sizeof(align) - ((u_long)bp % sizeof(align));
+ bp = (char *)(((u_long)bp + (sizeof(align) - 1)) &
+ ~(sizeof(align) - 1));
/* Avoid overflows. */
if (bp + n >= &pvt->hostbuf[sizeof pvt->hostbuf]) {
had_error++;
had_error++;
break;
}
+ if (m == 0)
+ continue;
if (hap < &pvt->h_addr_ptrs[MAXADDRS-1])
hap++;
{
int addrlen;
char *addrp;
+ const char **tap;
+ char *obp = bp;
switch(ai->ai_addr->sa_family) {
case AF_INET6:
return(-1); /* abort? */
}
- bp += sizeof(align) - ((u_long)bp % sizeof(align));
+ /* Ensure alignment. */
+ bp = (char *)(((u_long)bp + (sizeof(align) - 1)) &
+ ~(sizeof(align) - 1));
+ /* Avoid overflows. */
if (bp + addrlen >= &pvt->hostbuf[sizeof pvt->hostbuf])
return(-1);
if (hap >= &pvt->h_addr_ptrs[MAXADDRS-1])
- return(addrlen); /* fail, but not treat it as an error. */
-#if 0
+ return(0); /* fail, but not treat it as an error. */
+
/* Suppress duplicates. */
for (tap = (const char **)pvt->h_addr_ptrs;
*tap != NULL;
tap++)
- if (memcmp(*tap, cp, n) == 0)
+ if (memcmp(*tap, addrp, addrlen) == 0)
break;
- if (*tap != NULL) {
- cp += n;
- continue;
- }
-#endif
+ if (*tap != NULL)
+ return (0);
memcpy(*hap = bp, addrp, addrlen);
- return(addrlen);
+ return((bp + addrlen) - obp);
}
static void
hp->h_addrtype = AF_INET6;
hp->h_length = IN6ADDRSZ;
for (ap = hp->h_addr_list; *ap; ap++) {
- int i = sizeof(align) - ((u_long)*bpp % sizeof(align));
+ int i = (u_long)*bpp % sizeof(align);
+
+ if (i != 0)
+ i = sizeof(align) - i;
if (*lenp < (i + IN6ADDRSZ)) {
/* Out of memory. Truncate address list here. */