summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-03 18:41:26 -0700
committerJeremy Allison <jra@samba.org>2007-11-03 18:41:26 -0700
commit25074433f412c4dd2531fd268d51be8753ddc11b (patch)
tree2c18dde9c017a675f2ea75e76ae773bb9057ded5 /source3/lib
parent6658165d5e9cd186fea74e1581091233e8990e9b (diff)
downloadsamba-25074433f412c4dd2531fd268d51be8753ddc11b.tar.gz
samba-25074433f412c4dd2531fd268d51be8753ddc11b.tar.bz2
samba-25074433f412c4dd2531fd268d51be8753ddc11b.zip
I can't get away without a 'length' arg. :-).
Jeremy. (This used to be commit 95d01279a5def709d0a5d5ae7224d6286006d120)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/access.c8
-rw-r--r--source3/lib/substitute.c3
-rw-r--r--source3/lib/util_sock.c19
3 files changed, 16 insertions, 14 deletions
diff --git a/source3/lib/access.c b/source3/lib/access.c
index 31bc515b47..1e4df83607 100644
--- a/source3/lib/access.c
+++ b/source3/lib/access.c
@@ -358,24 +358,24 @@ bool check_access(int sock, const char **allow_list, const char **deny_list)
ret = allow_access(deny_list,
allow_list,
"",
- get_peer_addr(sock,addr));
+ get_peer_addr(sock,addr,sizeof(addr)));
} else {
DEBUG (3, ("check_access: hostnames in "
"host allow/deny list.\n"));
ret = allow_access(deny_list,
allow_list,
get_peer_name(sock,true),
- get_peer_addr(sock,addr));
+ get_peer_addr(sock,addr,sizeof(addr)));
}
if (ret) {
DEBUG(2,("Allowed connection from %s (%s)\n",
only_ip ? "" : get_peer_name(sock,true),
- get_peer_addr(sock,addr)));
+ get_peer_addr(sock,addr,sizeof(addr))));
} else {
DEBUG(0,("Denied connection from %s (%s)\n",
only_ip ? "" : get_peer_name(sock,true),
- get_peer_addr(sock,addr)));
+ get_peer_addr(sock,addr,sizeof(addr))));
}
}
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index a6195ef9d7..d4c7cd6467 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -495,7 +495,8 @@ char *alloc_sub_basic(const char *smb_name, const char *domain_name,
a_string = realloc_string_sub(a_string, "%D", r);
break;
case 'I' :
- a_string = realloc_string_sub(a_string, "%I", client_addr(addr));
+ a_string = realloc_string_sub(a_string, "%I",
+ client_addr(addr, sizeof(addr)));
break;
case 'i':
a_string = realloc_string_sub( a_string, "%i", client_socket_addr() );
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index b1e508182d..5422bc2180 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -590,7 +590,7 @@ void client_setfd(int fd)
char addr[INET6_ADDRSTRLEN];
client_fd = fd;
safe_strcpy(client_ip_string,
- get_peer_addr(client_fd,addr),
+ get_peer_addr(client_fd,addr,sizeof(addr)),
sizeof(client_ip_string)-1);
}
@@ -659,9 +659,9 @@ const char *client_name(void)
return get_peer_name(client_fd,false);
}
-const char *client_addr(char addr[INET6_ADDRSTRLEN])
+const char *client_addr(char *addr, size_t addrlen)
{
- return get_peer_addr(client_fd,addr);
+ return get_peer_addr(client_fd,addr,addrlen);
}
const char *client_socket_addr(void)
@@ -1700,14 +1700,15 @@ int open_udp_socket(const char *host, int port)
******************************************************************/
static const char *get_peer_addr_internal(int fd,
- char addr_buf[INET6_ADDRSTRLEN],
+ char *addr_buf,
+ size_t addr_buf_len,
struct sockaddr_storage *pss,
socklen_t *plength)
{
struct sockaddr_storage ss;
socklen_t length = sizeof(ss);
- safe_strcpy(addr_buf,"0.0.0.0",sizeof(addr_buf)-1);
+ safe_strcpy(addr_buf,"0.0.0.0",addr_buf_len-1);
if (fd == -1) {
return addr_buf;
@@ -1824,11 +1825,11 @@ const char *get_peer_name(int fd, bool force_lookup)
with dns. To avoid the delay we avoid the lookup if
possible */
if (!lp_hostname_lookups() && (force_lookup == false)) {
- pstrcpy(name_buf, get_peer_addr(fd, addr_buf));
+ pstrcpy(name_buf, get_peer_addr(fd, addr_buf, sizeof(addr_buf)));
return name_buf;
}
- p = get_peer_addr_internal(fd, addr_buf, &ss, &length);
+ p = get_peer_addr_internal(fd, addr_buf, sizeof(addr_buf), &ss, &length);
/* it might be the same as the last one - save some DNS work */
if (strcmp(p, addr_buf_cache) == 0) {
@@ -1881,9 +1882,9 @@ const char *get_peer_name(int fd, bool force_lookup)
Return the IP addr of the remote end of a socket as a string.
******************************************************************/
-const char *get_peer_addr(int fd, char addr[INET6_ADDRSTRLEN])
+const char *get_peer_addr(int fd, char *addr, size_t addr_len)
{
- return get_peer_addr_internal(fd, addr, NULL, NULL);
+ return get_peer_addr_internal(fd, addr, addr_len, NULL, NULL);
}
/*******************************************************************