diff options
Diffstat (limited to 'source/lib')
-rw-r--r-- | source/lib/access.c | 8 | ||||
-rw-r--r-- | source/lib/substitute.c | 3 | ||||
-rw-r--r-- | source/lib/util_sock.c | 19 |
3 files changed, 16 insertions, 14 deletions
diff --git a/source/lib/access.c b/source/lib/access.c index 31bc515b47d..1e4df836079 100644 --- a/source/lib/access.c +++ b/source/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/source/lib/substitute.c b/source/lib/substitute.c index a6195ef9d74..d4c7cd6467e 100644 --- a/source/lib/substitute.c +++ b/source/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/source/lib/util_sock.c b/source/lib/util_sock.c index b1e508182d6..5422bc21803 100644 --- a/source/lib/util_sock.c +++ b/source/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); } /******************************************************************* |