Remove a now-defunct variable.

This commit is contained in:
Jung-uk Kim 2011-10-06 21:40:08 +00:00
parent 3106d6704b
commit b6f96462ba

View File

@ -81,7 +81,7 @@ static int linux_to_bsd_domain(int);
* family and convert to sockaddr. * family and convert to sockaddr.
*/ */
static int static int
linux_getsockaddr(struct sockaddr **sap, const struct osockaddr *osa, int osalen) linux_getsockaddr(struct sockaddr **sap, const struct osockaddr *osa, int salen)
{ {
struct sockaddr *sa; struct sockaddr *sa;
struct osockaddr *kosa; struct osockaddr *kosa;
@ -90,12 +90,11 @@ linux_getsockaddr(struct sockaddr **sap, const struct osockaddr *osa, int osalen
int oldv6size; int oldv6size;
#endif #endif
char *name; char *name;
int alloclen, bdom, error, hdrlen, namelen; int bdom, error, hdrlen, namelen;
if (osalen < 2 || osalen > UCHAR_MAX || !osa) if (salen < 2 || salen > UCHAR_MAX || !osa)
return (EINVAL); return (EINVAL);
alloclen = osalen;
#ifdef INET6 #ifdef INET6
oldv6size = 0; oldv6size = 0;
/* /*
@ -103,15 +102,15 @@ linux_getsockaddr(struct sockaddr **sap, const struct osockaddr *osa, int osalen
* if it's a v4-mapped address, so reserve the proper space * if it's a v4-mapped address, so reserve the proper space
* for it. * for it.
*/ */
if (alloclen == sizeof(struct sockaddr_in6) - sizeof(uint32_t)) { if (salen == sizeof(struct sockaddr_in6) - sizeof(uint32_t)) {
alloclen = sizeof(struct sockaddr_in6); salen += sizeof(uint32_t);
oldv6size = 1; oldv6size = 1;
} }
#endif #endif
kosa = malloc(alloclen, M_SONAME, M_WAITOK); kosa = malloc(salen, M_SONAME, M_WAITOK);
if ((error = copyin(osa, kosa, osalen))) if ((error = copyin(osa, kosa, salen)))
goto out; goto out;
bdom = linux_to_bsd_domain(kosa->sa_family); bdom = linux_to_bsd_domain(kosa->sa_family);
@ -145,18 +144,18 @@ linux_getsockaddr(struct sockaddr **sap, const struct osockaddr *osa, int osalen
goto out; goto out;
} }
} else } else
alloclen -= sizeof(uint32_t); salen -= sizeof(uint32_t);
} }
#endif #endif
if (bdom == AF_INET) { if (bdom == AF_INET) {
alloclen = sizeof(struct sockaddr_in); if (salen < sizeof(struct sockaddr_in)) {
if (osalen < alloclen) {
error = EINVAL; error = EINVAL;
goto out; goto out;
} }
salen = sizeof(struct sockaddr_in);
} }
if (bdom == AF_LOCAL && osalen > sizeof(struct sockaddr_un)) { if (bdom == AF_LOCAL && salen > sizeof(struct sockaddr_un)) {
hdrlen = offsetof(struct sockaddr_un, sun_path); hdrlen = offsetof(struct sockaddr_un, sun_path);
name = ((struct sockaddr_un *)kosa)->sun_path; name = ((struct sockaddr_un *)kosa)->sun_path;
if (*name == '\0') { if (*name == '\0') {
@ -164,19 +163,19 @@ linux_getsockaddr(struct sockaddr **sap, const struct osockaddr *osa, int osalen
* Linux abstract namespace starts with a NULL byte. * Linux abstract namespace starts with a NULL byte.
* XXX We do not support abstract namespace yet. * XXX We do not support abstract namespace yet.
*/ */
namelen = strnlen(name + 1, osalen - hdrlen - 1) + 1; namelen = strnlen(name + 1, salen - hdrlen - 1) + 1;
} else } else
namelen = strnlen(name, osalen - hdrlen); namelen = strnlen(name, salen - hdrlen);
if (hdrlen + namelen > sizeof(struct sockaddr_un)) { if (hdrlen + namelen > sizeof(struct sockaddr_un)) {
error = ENAMETOOLONG; error = ENAMETOOLONG;
goto out; goto out;
} }
alloclen = sizeof(struct sockaddr_un); salen = sizeof(struct sockaddr_un);
} }
sa = (struct sockaddr *)kosa; sa = (struct sockaddr *)kosa;
sa->sa_family = bdom; sa->sa_family = bdom;
sa->sa_len = alloclen; sa->sa_len = salen;
*sap = sa; *sap = sa;
return (0); return (0);