mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 20:40:05 +00:00
* inet/rcmd.c (rresvport_af): Change ss to anonymous union
in order to avoid strict alias warnings. (iruserok_af): Ditto for ra.
This commit is contained in:
parent
265cbed8e7
commit
eb286115b1
@ -1,3 +1,10 @@
|
||||
2015-05-19 Paul Eggert <eggert@cs.ucla.edu>
|
||||
Steve Ellcey <sellcey@imgtec.com>
|
||||
|
||||
* inet/rcmd.c (rresvport_af): Change ss to anonymous union
|
||||
in order to avoid strict alias warnings.
|
||||
(iruserok_af): Ditto for ra.
|
||||
|
||||
2015-05-19 James Lemke <jwlemke@codesourcery.com>
|
||||
|
||||
[BZ #17581]
|
||||
|
34
inet/rcmd.c
34
inet/rcmd.c
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user