diff options
author | Jeremy Allison <jra@samba.org> | 2007-11-03 18:41:26 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2007-11-03 18:41:26 -0700 |
commit | 95d01279a5def709d0a5d5ae7224d6286006d120 (patch) | |
tree | 5d257a2255ea2872189f1c3ec70dfd58356a9f9d /source | |
parent | e848506c858bd16706c1d7f6b4b032005512b8ac (diff) | |
download | samba-95d01279a5def709d0a5d5ae7224d6286006d120.tar.gz samba-95d01279a5def709d0a5d5ae7224d6286006d120.tar.xz samba-95d01279a5def709d0a5d5ae7224d6286006d120.zip |
I can't get away without a 'length' arg. :-).
Jeremy.
Diffstat (limited to 'source')
-rw-r--r-- | source/auth/pampass.c | 2 | ||||
-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 | ||||
-rw-r--r-- | source/modules/vfs_expand_msdfs.c | 3 | ||||
-rw-r--r-- | source/printing/print_cups.c | 2 | ||||
-rw-r--r-- | source/printing/print_iprint.c | 2 | ||||
-rw-r--r-- | source/rpc_server/srv_netlog_nt.c | 2 | ||||
-rw-r--r-- | source/smbd/connection.c | 2 | ||||
-rw-r--r-- | source/smbd/process.c | 3 | ||||
-rw-r--r-- | source/smbd/server.c | 6 | ||||
-rw-r--r-- | source/smbd/service.c | 6 | ||||
-rw-r--r-- | source/smbd/session.c | 4 | ||||
-rw-r--r-- | source/smbd/sesssetup.c | 3 | ||||
-rw-r--r-- | source/web/cgi.c | 2 |
15 files changed, 38 insertions, 29 deletions
diff --git a/source/auth/pampass.c b/source/auth/pampass.c index 9b8faf16092..c7ec79b9694 100644 --- a/source/auth/pampass.c +++ b/source/auth/pampass.c @@ -470,7 +470,7 @@ static bool smb_pam_start(pam_handle_t **pamh, const char *user, const char *rho if (rhost == NULL) { our_rhost = client_name(); if (strequal(our_rhost,"UNKNOWN")) - our_rhost = client_addr(addr); + our_rhost = client_addr(addr,sizeof(addr)); } else { our_rhost = rhost; } 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); } /******************************************************************* diff --git a/source/modules/vfs_expand_msdfs.c b/source/modules/vfs_expand_msdfs.c index 12f2c8e72b0..4b670d5172c 100644 --- a/source/modules/vfs_expand_msdfs.c +++ b/source/modules/vfs_expand_msdfs.c @@ -71,7 +71,8 @@ static bool read_target_host(const char *mapfile, pstring targethost) *space = '\0'; - if (strncmp(client_addr(addr), buf, strlen(buf)) == 0) { + if (strncmp(client_addr(addr,sizeof(addr)), + buf, strlen(buf)) == 0) { found = True; break; } diff --git a/source/printing/print_cups.c b/source/printing/print_cups.c index ff4c7ebc5f5..5709d936243 100644 --- a/source/printing/print_cups.c +++ b/source/printing/print_cups.c @@ -620,7 +620,7 @@ static int cups_job_submit(int snum, struct printjob *pjob) clientname = client_name(); if (strcmp(clientname, "UNKNOWN") == 0) { - clientname = client_addr(addr); + clientname = client_addr(addr,sizeof(addr)); } ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, diff --git a/source/printing/print_iprint.c b/source/printing/print_iprint.c index 8ee681b3be5..6dd19577f14 100644 --- a/source/printing/print_iprint.c +++ b/source/printing/print_iprint.c @@ -781,7 +781,7 @@ static int iprint_job_submit(int snum, struct printjob *pjob) clientname = client_name(); if (strcmp(clientname, "UNKNOWN") == 0) { - clientname = client_addr(addr); + clientname = client_addr(addr,sizeof(addr)); } ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, diff --git a/source/rpc_server/srv_netlog_nt.c b/source/rpc_server/srv_netlog_nt.c index 6de8cd75723..f876ee976df 100644 --- a/source/rpc_server/srv_netlog_nt.c +++ b/source/rpc_server/srv_netlog_nt.c @@ -210,7 +210,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) */ if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(), - client_name(), client_addr(addr))) + client_name(), client_addr(addr,sizeof(addr)))) { DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct)); return False; diff --git a/source/smbd/connection.c b/source/smbd/connection.c index 4b896686400..f0415138204 100644 --- a/source/smbd/connection.c +++ b/source/smbd/connection.c @@ -152,7 +152,7 @@ bool claim_connection(connection_struct *conn, const char *name, crec.bcast_msg_flags = msg_flags; strlcpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine)); - strlcpy(crec.addr,conn?conn->client_address:client_addr(addr), + strlcpy(crec.addr,conn?conn->client_address:client_addr(addr,sizeof(addr)), sizeof(crec.addr)); dbuf.dptr = (uint8 *)&crec; diff --git a/source/smbd/process.c b/source/smbd/process.c index f35e7054d77..24feac46309 100644 --- a/source/smbd/process.c +++ b/source/smbd/process.c @@ -1471,7 +1471,8 @@ static void process_smb(char *inbuf, size_t nread, size_t unread_bytes) lp_hostsdeny(-1))) { /* send a negative session response "not listening on calling name" */ static unsigned char buf[5] = {0x83, 0, 0, 1, 0x81}; - DEBUG( 1, ( "Connection denied from %s\n", client_addr(addr) ) ); + DEBUG( 1, ( "Connection denied from %s\n", + client_addr(addr,sizeof(addr)) ) ); (void)send_smb(smbd_server_fd(),(char *)buf); exit_server_cleanly("connection denied"); } diff --git a/source/smbd/server.c b/source/smbd/server.c index 34b3d4a32a8..e77573b9c6b 100644 --- a/source/smbd/server.c +++ b/source/smbd/server.c @@ -624,8 +624,10 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ /* this is needed so that we get decent entries in smbstatus for port 445 connects */ - set_remote_machine_name(get_peer_addr(smbd_server_fd(),remaddr), - False); + set_remote_machine_name(get_peer_addr(smbd_server_fd(), + remaddr, + sizeof(remaddr)), + false); /* Reset the state of the random * number generation system, so diff --git a/source/smbd/service.c b/source/smbd/service.c index 2901cd3417c..502fadedc75 100644 --- a/source/smbd/service.c +++ b/source/smbd/service.c @@ -758,7 +758,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser, add_session_user(user); - safe_strcpy(conn->client_address, client_addr(addr), + safe_strcpy(conn->client_address, client_addr(addr,sizeof(addr)), sizeof(conn->client_address)-1); conn->num_files_open = 0; conn->lastused = conn->lastused_count = time(NULL); @@ -1302,7 +1302,9 @@ connection_struct *make_connection(const char *service_in, DATA_BLOB password, } DEBUG(0,("%s (%s) couldn't find service %s\n", - get_remote_machine_name(), client_addr(addr), service)); + get_remote_machine_name(), + client_addr(addr,sizeof(addr)), + service)); *status = NT_STATUS_BAD_NETWORK_NAME; return NULL; } diff --git a/source/smbd/session.c b/source/smbd/session.c index 15154162b95..69f4a37c850 100644 --- a/source/smbd/session.c +++ b/source/smbd/session.c @@ -161,7 +161,7 @@ bool session_claim(user_struct *vuser) hostname = client_name(); if (strcmp(hostname, "UNKNOWN") == 0) { - hostname = client_addr(addr); + hostname = client_addr(addr,sizeof(addr)); } fstrcpy(sessionid.username, vuser->user.unix_name); @@ -171,7 +171,7 @@ bool session_claim(user_struct *vuser) sessionid.uid = vuser->uid; sessionid.gid = vuser->gid; fstrcpy(sessionid.remote_machine, get_remote_machine_name()); - fstrcpy(sessionid.ip_addr_str, client_addr(addr)); + fstrcpy(sessionid.ip_addr_str, client_addr(addr,sizeof(addr))); sessionid.connect_start = time(NULL); if (!smb_pam_claim_session(sessionid.username, sessionid.id_str, diff --git a/source/smbd/sesssetup.c b/source/smbd/sesssetup.c index 35efbc009f9..87cb3b435b3 100644 --- a/source/smbd/sesssetup.c +++ b/source/smbd/sesssetup.c @@ -1317,7 +1317,8 @@ static void setup_new_vc_session(void) #endif if (lp_reset_on_zero_vc()) { connections_forall(shutdown_other_smbds, - CONST_DISCARD(void *,client_addr(addr))); + CONST_DISCARD(void *, + client_addr(addr,sizeof(addr)))); } } diff --git a/source/web/cgi.c b/source/web/cgi.c index 71328459f0a..41ac29be5d2 100644 --- a/source/web/cgi.c +++ b/source/web/cgi.c @@ -648,7 +648,7 @@ const char *cgi_remote_addr(void) { if (inetd_server) { char addr[INET6_ADDRSTRLEN]; - return get_peer_addr(1,addr); + return get_peer_addr(1,addr,sizeof(addr)); } return getenv("REMOTE_ADDR"); } |