CMSG_XXX macros alignment fixes to follow RFC2292.

Approved by: jkh


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@57724 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
This commit is contained in:
shin 2000-03-03 12:50:46 +00:00
parent 2d4e3ed569
commit 5137153b86

View File

@ -3058,19 +3058,18 @@ sourceroute(ai, arg, cpp, lenp, protop, optp)
* at least 7 bytes for the option. * at least 7 bytes for the option.
*/ */
if (cpp == NULL || lenp == NULL) if (cpp == NULL || lenp == NULL)
return((unsigned long)-1); return -1;
if (*cpp != NULL) { if (*cpp != NULL) {
switch (res->ai_family) { switch (res->ai_family) {
case AF_INET: case AF_INET:
if (*lenp < 7) if (*lenp < 7)
return((unsigned long)-1); return -1;
break; break;
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
if (*lenp < (sizeof(struct cmsghdr) + if (*lenp < CMSG_SPACE(sizeof(struct ip6_rthdr) +
sizeof(struct ip6_rthdr) + sizeof(struct in6_addr)))
sizeof(struct in6_addr))) return -1;
return((unsigned long)-1);
break; break;
#endif #endif
} }
@ -3083,7 +3082,7 @@ sourceroute(ai, arg, cpp, lenp, protop, optp)
lsrp = *cpp; lsrp = *cpp;
ep = lsrp + *lenp; ep = lsrp + *lenp;
} else { } else {
*cpp = lsrp = buf; *cpp = lsrp = ALIGN(buf);
ep = lsrp + 1024; ep = lsrp + 1024;
} }
@ -3119,7 +3118,7 @@ sourceroute(ai, arg, cpp, lenp, protop, optp)
#endif #endif
if (*cp != '@') if (*cp != '@')
return((unsigned long)-1); return -1;
#ifndef sysV88 #ifndef sysV88
lsrp++; /* skip over length, we'll fill it in later */ lsrp++; /* skip over length, we'll fill it in later */
@ -3195,16 +3194,15 @@ sourceroute(ai, arg, cpp, lenp, protop, optp)
*/ */
#ifdef INET6 #ifdef INET6
if (res->ai_family == AF_INET6) { if (res->ai_family == AF_INET6) {
if (((char *)cmsg + if (((char *)CMSG_DATA(cmsg) +
sizeof(struct cmsghdr) +
sizeof(struct ip6_rthdr) + sizeof(struct ip6_rthdr) +
((inet6_rthdr_segments(cmsg) + 1) * ((inet6_rthdr_segments(cmsg) + 1) *
sizeof(struct in6_addr))) > ep) sizeof(struct in6_addr))) > ep)
return((unsigned long)-1); return -1;
} else } else
#endif #endif
if (lsrp + 4 > ep) if (lsrp + 4 > ep)
return((unsigned long)-1); return -1;
freeaddrinfo(res); freeaddrinfo(res);
} }
#ifdef INET6 #ifdef INET6
@ -3218,7 +3216,7 @@ sourceroute(ai, arg, cpp, lenp, protop, optp)
if ((*(*cpp+IPOPT_OLEN) = lsrp - *cpp) <= 7) { if ((*(*cpp+IPOPT_OLEN) = lsrp - *cpp) <= 7) {
*cpp = 0; *cpp = 0;
*lenp = 0; *lenp = 0;
return((unsigned long)-1); return -1;
} }
*lsrp++ = IPOPT_NOP; /* 32 bit word align it */ *lsrp++ = IPOPT_NOP; /* 32 bit word align it */
*lenp = lsrp - *cpp; *lenp = lsrp - *cpp;
@ -3227,7 +3225,7 @@ sourceroute(ai, arg, cpp, lenp, protop, optp)
if (ipopt.io_len <= 5) { /* Is 3 better ? */ if (ipopt.io_len <= 5) { /* Is 3 better ? */
*cpp = 0; *cpp = 0;
*lenp = 0; *lenp = 0;
return((unsigned long)-1); return -1;
} }
*lenp = sizeof(ipopt); *lenp = sizeof(ipopt);
*cpp = (char *) &ipopt; *cpp = (char *) &ipopt;