diff options
Diffstat (limited to 'inet/rcmd.c')
-rw-r--r-- | inet/rcmd.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/inet/rcmd.c b/inet/rcmd.c index acacaa0..98b3735 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -114,10 +114,10 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) struct addrinfo hints, *res, *ai; union { - struct sockaddr sa; - struct sockaddr_storage ss; - struct sockaddr_in sin; - struct sockaddr_in6 sin6; + struct sockaddr sa; + struct sockaddr_storage ss; + struct sockaddr_in sin; + struct sockaddr_in6 sin6; } from; struct pollfd pfd[2]; int32_t oldmask; @@ -374,7 +374,11 @@ rresvport_af(alport, family) int *alport; sa_family_t family; { - struct sockaddr_storage ss; + union { + struct sockaddr generic; + struct sockaddr_in in; + struct sockaddr_in6 in6; + } ss; int s; size_t len; uint16_t *sport; @@ -382,11 +386,11 @@ rresvport_af(alport, family) switch(family){ case AF_INET: len = sizeof(struct sockaddr_in); - sport = &((struct sockaddr_in *)&ss)->sin_port; + sport = &ss.in.sin_port; break; case AF_INET6: len = sizeof(struct sockaddr_in6); - sport = &((struct sockaddr_in6 *)&ss)->sin6_port; + sport = &ss.in6.sin6_port; break; default: __set_errno (EAFNOSUPPORT); @@ -398,9 +402,9 @@ rresvport_af(alport, family) memset (&ss, '\0', sizeof(ss)); #ifdef SALEN - ss.__ss_len = len; + ss.generic.__ss_len = len; #endif - ss.ss_family = family; + ss.generic.sa_family = family; /* Ignore invalid values. */ if (*alport < IPPORT_RESERVED / 2) @@ -411,7 +415,7 @@ rresvport_af(alport, family) int start = *alport; do { *sport = htons((uint16_t) *alport); - if (__bind(s, (struct sockaddr *)&ss, len) >= 0) + if (__bind(s, &ss.generic, len) >= 0) return s; if (errno != EADDRINUSE) { (void)__close(s); @@ -604,27 +608,29 @@ iruserok_af (raddr, superuser, ruser, luser, af) const char *ruser, *luser; sa_family_t af; { - struct sockaddr_storage ra; + union { + struct sockaddr generic; + struct sockaddr_in in; + struct sockaddr_in6 in6; + } ra; size_t ralen; memset (&ra, '\0', sizeof(ra)); switch (af){ case AF_INET: - ra.ss_family = AF_INET; - memcpy (&(((struct sockaddr_in *)&ra)->sin_addr), raddr, - sizeof(struct in_addr)); + ra.in.sin_family = AF_INET; + memcpy (&ra.in.sin_addr, raddr, sizeof(struct in_addr)); ralen = sizeof(struct sockaddr_in); break; case AF_INET6: - ra.ss_family = AF_INET6; - memcpy (&(((struct sockaddr_in6 *)&ra)->sin6_addr), raddr, - sizeof(struct in6_addr)); + ra.in6.sin6_family = AF_INET6; + memcpy (&ra.in6.sin6_addr, raddr, sizeof(struct in6_addr)); ralen = sizeof(struct sockaddr_in6); break; default: return 0; } - return ruserok_sa ((struct sockaddr *)&ra, ralen, superuser, ruser, luser); + return ruserok_sa (&ra.generic, ralen, superuser, ruser, luser); } libc_hidden_def (iruserok_af) |