diff options
author | Olaf Kirch <okir@suse.de> | 2008-09-30 14:44:05 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2008-09-30 14:44:05 -0400 |
commit | 49e8a7c963c27ca3face271200b103a5efc50b05 (patch) | |
tree | 5ce234b780691f13123ccfa1eb6b6765c5badf53 | |
parent | 62a20676c31a1887f8151a5b0ca42932205c4f4b (diff) | |
download | rpcbind-49e8a7c963c27ca3face271200b103a5efc50b05.tar.gz |
Fix debug output in is_loopback
The security check in is_loopback wants to print the source
port number, assuming that the remote address is always a
sockaddr_in - which is silly. Move the printf into the
address family specific switch statement.
Signed-off-by: Olaf Kirch <okir@suse.de>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | src/security.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/security.c b/src/security.c index 7e6f3a9..6fc4280 100644 --- a/src/security.c +++ b/src/security.c @@ -138,16 +138,18 @@ is_loopback(struct netbuf *nbuf) #ifdef INET6 struct sockaddr_in6 *sin6; #endif -#ifdef RPCBIND_DEBUG - if (debugging) - fprintf(stderr,"Checking caller's adress (port = 0x%x)\n", - ((struct sockaddr_in *)addr)->sin_port); -#endif + switch (addr->sa_family) { case AF_INET: if (!oldstyle_local) return 0; sin = (struct sockaddr_in *)addr; +#ifdef RPCBIND_DEBUG + if (debugging) + fprintf(stderr, + "Checking caller's adress (port = %d)\n", + ntohs(sin->sin_port)); +#endif return ((sin->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) && (ntohs(sin->sin_port) < IPPORT_RESERVED)); #ifdef INET6 @@ -155,6 +157,12 @@ is_loopback(struct netbuf *nbuf) if (!oldstyle_local) return 0; sin6 = (struct sockaddr_in6 *)addr; +#ifdef RPCBIND_DEBUG + if (debugging) + fprintf(stderr, + "Checking caller's adress (port = %d)\n", + ntohs(sin6->sin6_port)); +#endif return ((IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr) || (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr) && sin6->sin6_addr.s6_addr32[3] == htonl(INADDR_LOOPBACK))) && |