summaryrefslogtreecommitdiff
path: root/clientname.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2002-08-02 17:11:39 +0000
committerWayne Davison <wayned@samba.org>2002-08-02 17:11:39 +0000
commit3b5f6214a6b9422bb320e0f954cc93477f4b0e23 (patch)
treed9d62a5af31c4096e29b641c9bc61e800f0061da /clientname.c
parent542ad675b9d241d5c508e49bd6b324658728c4e9 (diff)
downloadrsync-3b5f6214a6b9422bb320e0f954cc93477f4b0e23.tar.gz
rsync-3b5f6214a6b9422bb320e0f954cc93477f4b0e23.tar.bz2
rsync-3b5f6214a6b9422bb320e0f954cc93477f4b0e23.zip
* Don't call getnameinfo() if we've already populated the addr_buf.
* Moved some structures in client_name() so that they remain in-scope for the entire function (since we set pointers to their storage location). * Allow the dot-counting loop to increment to 4 instead of stopping at 3.
Diffstat (limited to 'clientname.c')
-rw-r--r--clientname.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/clientname.c b/clientname.c
index 9bd15cb4..95dadd52 100644
--- a/clientname.c
+++ b/clientname.c
@@ -67,11 +67,11 @@ char *client_addr(int fd)
*(addr_buf + len) = '\0';
}
}
- } else
+ } else {
client_sockaddr(fd, &ss, &length);
-
- getnameinfo((struct sockaddr *)&ss, length,
- addr_buf, sizeof(addr_buf), NULL, 0, NI_NUMERICHOST);
+ getnameinfo((struct sockaddr *)&ss, length,
+ addr_buf, sizeof addr_buf, NULL, 0, NI_NUMERICHOST);
+ }
return addr_buf;
}
@@ -101,7 +101,11 @@ char *client_name(int fd)
static char name_buf[100];
static char port_buf[100];
static int initialised;
- struct sockaddr_storage *ssp;
+ struct sockaddr_storage ss, *ssp;
+ struct sockaddr_in sin;
+#ifdef INET6
+ struct sockaddr_in6 sin6;
+#endif
socklen_t ss_len;
if (initialised) return name_buf;
@@ -113,13 +117,11 @@ char *client_name(int fd)
/* daemon over --rsh mode */
char *addr = client_addr(fd);
- struct sockaddr_in sin;
#ifdef INET6
int dots = 0;
char *p;
- struct sockaddr_in6 sin6;
- for (p = addr; *p && (dots < 3); p++) {
+ for (p = addr; *p && (dots <= 3); p++) {
if (*p == '.')
dots++;
}
@@ -141,8 +143,6 @@ char *client_name(int fd)
}
} else {
- struct sockaddr_storage ss;
-
ss_len = sizeof ss;
ssp = &ss;