From: Chris Provenzano Date: Mon, 1 May 1995 21:09:37 +0000 (+0000) Subject: * genaddrs.c (krb5_auth_con_genaddrs()), X-Git-Tag: krb5-1.0-beta5~75 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c7efcd53fa9aefb83d09dbb76c323e6a8d59f074;p=krb5.git * genaddrs.c (krb5_auth_con_genaddrs()), * mk_faddr.c (krb5_make_fulladdr()), os-proto.h : Changes to auth_context to better support full addresses. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5678 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index db46bdf58..561f3f28b 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,9 @@ +Mon May 01 15:56:32 1995 Chris Provenzano (proven@mit.edu) + + * genaddrs.c (krb5_auth_con_genaddrs()), + * mk_faddr.c (krb5_make_fulladdr()), os-proto.h : + Changes to auth_context to better support full addresses. + Sun Apr 30 16:03:59 1995 Ezra Peisach * osconfig.c: Global variables krb5_config_file and diff --git a/src/lib/krb5/os/genaddrs.c b/src/lib/krb5/os/genaddrs.c index f13ea09cf..4f7e2b9e3 100644 --- a/src/lib/krb5/os/genaddrs.c +++ b/src/lib/krb5/os/genaddrs.c @@ -39,56 +39,65 @@ krb5_auth_con_genaddrs(context, auth_context, fd, flags) int fd, flags; { krb5_error_code retval; - krb5_address * laddr; - krb5_address * raddr; + krb5_address * laddr; + krb5_address * lport; + krb5_address * raddr; + krb5_address * rport; #ifdef KRB5_USE_INET - struct sockaddr_in saddr; - krb5_address lcaddr; - krb5_address rcaddr; + struct sockaddr_in lsaddr, rsaddr; + krb5_address lcaddr, rcaddr; + krb5_address lcport, rcport; int ssize; ssize = sizeof(struct sockaddr); if ((flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR) || (flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR)) { - if (retval = getsockname(fd, (struct sockaddr *) &saddr, &ssize)) + if (retval = getsockname(fd, (struct sockaddr *) &lsaddr, &ssize)) return retval; if (flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR) { - if (retval = krb5_make_fulladdr(context, &saddr, &lcaddr)) - return retval; - } else { - lcaddr.contents = (krb5_octet *)&saddr.sin_addr; - lcaddr.length = sizeof(saddr.sin_addr); - lcaddr.addrtype = ADDRTYPE_INET; - } + lcport.contents = (krb5_octet *)&lsaddr.sin_port; + lcport.length = sizeof(lsaddr.sin_port); + lcport.addrtype = ADDRTYPE_IPPORT; + lport = &lcport; + } else { + lport = NULL; + } + lcaddr.contents = (krb5_octet *)&lsaddr.sin_addr; + lcaddr.length = sizeof(lsaddr.sin_addr); + lcaddr.addrtype = ADDRTYPE_INET; laddr = &lcaddr; } else { laddr = NULL; + lport = NULL; } if ((flags & KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR) || (flags & KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR)) { - if (retval = getpeername(fd, (struct sockaddr *) &saddr, &ssize)) + if (retval = getpeername(fd, (struct sockaddr *) &rsaddr, &ssize)) return retval; if (flags & KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR) { - if (retval = krb5_make_fulladdr(context, &saddr, &rcaddr)) { - if (flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR) - krb5_xfree(laddr->contents); - return retval; - } - } else { - rcaddr.contents = (krb5_octet *)&saddr.sin_addr; - rcaddr.length = sizeof(saddr.sin_addr); - rcaddr.addrtype = ADDRTYPE_INET; + rcport.contents = (krb5_octet *)&rsaddr.sin_port; + rcport.length = sizeof(rsaddr.sin_port); + rcport.addrtype = ADDRTYPE_IPPORT; + rport = &rcport; + } else { + rport = NULL; } + rcaddr.contents = (krb5_octet *)&rsaddr.sin_addr; + rcaddr.length = sizeof(rsaddr.sin_addr); + rcaddr.addrtype = ADDRTYPE_INET; raddr = &rcaddr; } else { raddr = NULL; + rport = NULL; } - return (krb5_auth_con_setaddrs(context, auth_context, laddr, raddr)); + if (!(retval = krb5_auth_con_setaddrs(context, auth_context, laddr, raddr))) + return (krb5_auth_con_setports(context, auth_context, lport, rport)); + return retval; #else return KRB5_PROG_ATYPE_NOSUPP; #endif diff --git a/src/lib/krb5/os/mk_faddr.c b/src/lib/krb5/os/mk_faddr.c index e2256418d..8708f8f4b 100644 --- a/src/lib/krb5/os/mk_faddr.c +++ b/src/lib/krb5/os/mk_faddr.c @@ -35,56 +35,55 @@ #endif krb5_error_code -krb5_make_fulladdr(context, saddr, kaddr) +krb5_make_fulladdr(context, kaddr, kport, raddr) krb5_context context; - struct sockaddr_in * saddr; krb5_address * kaddr; + krb5_address * kport; + krb5_address * raddr; { - krb5_int32 smushaddr = (krb5_int32)saddr->sin_addr.s_addr; /* net order */ - krb5_int16 smushport = (krb5_int16)saddr->sin_port; /* ditto */ register krb5_octet * marshal; krb5_int32 tmp32; krb5_int16 tmp16; - kaddr->addrtype = ADDRTYPE_ADDRPORT; - kaddr->length = sizeof(saddr->sin_addr) + sizeof(saddr->sin_port) + - (4 * sizeof(krb5_int32)); + if ((kport == NULL) || (kport == NULL)) + return EINVAL; - if (!(kaddr->contents = (krb5_octet *)malloc(kaddr->length))) + raddr->length = kaddr->length + kport->length + (4 * sizeof(krb5_int32)); + if (!(raddr->contents = (krb5_octet *)malloc(kaddr->length))) return ENOMEM; - marshal = kaddr->contents; + raddr->addrtype = ADDRTYPE_ADDRPORT; + marshal = raddr->contents; - tmp16 = ADDRTYPE_INET; + tmp16 = kaddr->addrtype; *marshal++ = 0x00; *marshal++ = 0x00; *marshal++ = (krb5_octet) (tmp16 & 0xff); *marshal++ = (krb5_octet) ((tmp16 >> 8) & 0xff); - tmp32 = sizeof(smushaddr); + tmp32 = kaddr->length; *marshal++ = (krb5_octet) (tmp32 & 0xff); *marshal++ = (krb5_octet) ((tmp32 >> 8) & 0xff); *marshal++ = (krb5_octet) ((tmp32 >> 16) & 0xff); *marshal++ = (krb5_octet) ((tmp32 >> 24) & 0xff); - (void) memcpy((char *)marshal, (char *)&smushaddr, sizeof(smushaddr)); - marshal += sizeof(smushaddr); + (void) memcpy((char *)marshal, (char *)(kaddr->contents), kaddr->length); + marshal += kaddr->length; - tmp16 = ADDRTYPE_IPPORT; + tmp16 = kport->addrtype; *marshal++ = 0x00; *marshal++ = 0x00; *marshal++ = (krb5_octet) (tmp16 & 0xff); *marshal++ = (krb5_octet) ((tmp16 >> 8) & 0xff); - tmp32 = sizeof(smushport); + tmp32 = kport->length; *marshal++ = (krb5_octet) (tmp32 & 0xff); *marshal++ = (krb5_octet) ((tmp32 >> 8) & 0xff); *marshal++ = (krb5_octet) ((tmp32 >> 16) & 0xff); *marshal++ = (krb5_octet) ((tmp32 >> 24) & 0xff); - (void) memcpy((char *)marshal, (char *)&smushport, sizeof(smushport)); - marshal += sizeof(smushport); - + (void) memcpy((char *)marshal, (char *)(kport->contents), kport->length); + marshal += kport->length; return 0; } #endif diff --git a/src/lib/krb5/os/os-proto.h b/src/lib/krb5/os/os-proto.h index 895923c38..7b6fe4c6c 100644 --- a/src/lib/krb5/os/os-proto.h +++ b/src/lib/krb5/os/os-proto.h @@ -51,7 +51,8 @@ krb5_error_code krb5_make_full_ipaddr krb5_error_code krb5_make_fulladdr PROTOTYPE((krb5_context, - struct sockaddr_in *, + krb5_address *, + krb5_address *, krb5_address *)); #endif /* KRB5_USE_INET */