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 | 25074433f412c4dd2531fd268d51be8753ddc11b (patch) | |
tree | 2c18dde9c017a675f2ea75e76ae773bb9057ded5 /source3 | |
parent | 6658165d5e9cd186fea74e1581091233e8990e9b (diff) | |
download | samba-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')
-rw-r--r-- | source3/auth/pampass.c | 2 | ||||
-rw-r--r-- | source3/lib/access.c | 8 | ||||
-rw-r--r-- | source3/lib/substitute.c | 3 | ||||
-rw-r--r-- | source3/lib/util_sock.c | 19 | ||||
-rw-r--r-- | source3/modules/vfs_expand_msdfs.c | 3 | ||||
-rw-r--r-- | source3/printing/print_cups.c | 2 | ||||
-rw-r--r-- | source3/printing/print_iprint.c | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_netlog_nt.c | 2 | ||||
-rw-r--r-- | source3/smbd/connection.c | 2 | ||||
-rw-r--r-- | source3/smbd/process.c | 3 | ||||
-rw-r--r-- | source3/smbd/server.c | 6 | ||||
-rw-r--r-- | source3/smbd/service.c | 6 | ||||
-rw-r--r-- | source3/smbd/session.c | 4 | ||||
-rw-r--r-- | source3/smbd/sesssetup.c | 3 | ||||
-rw-r--r-- | source3/web/cgi.c | 2 |
15 files changed, 38 insertions, 29 deletions
diff --git a/source3/auth/pampass.c b/source3/auth/pampass.c index 9b8faf1609..c7ec79b969 100644 --- a/source3/auth/pampass.c +++ b/source3/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/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); } /******************************************************************* diff --git a/source3/modules/vfs_expand_msdfs.c b/source3/modules/vfs_expand_msdfs.c index 12f2c8e72b..4b670d5172 100644 --- a/source3/modules/vfs_expand_msdfs.c +++ b/source3/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/source3/printing/print_cups.c b/source3/printing/print_cups.c index ff4c7ebc5f..5709d93624 100644 --- a/source3/printing/print_cups.c +++ b/source3/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/source3/printing/print_iprint.c b/source3/printing/print_iprint.c index 8ee681b3be..6dd19577f1 100644 --- a/source3/printing/print_iprint.c +++ b/source3/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/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 6de8cd7572..f876ee976d 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/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/source3/smbd/connection.c b/source3/smbd/connection.c index 4b89668640..f041513820 100644 --- a/source3/smbd/connection.c +++ b/source3/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/source3/smbd/process.c b/source3/smbd/process.c index f35e7054d7..24feac4630 100644 --- a/source3/smbd/process.c +++ b/source3/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/source3/smbd/server.c b/source3/smbd/server.c index 34b3d4a32a..e77573b9c6 100644 --- a/source3/smbd/server.c +++ b/source3/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/source3/smbd/service.c b/source3/smbd/service.c index 2901cd3417..502fadedc7 100644 --- a/source3/smbd/service.c +++ b/source3/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/source3/smbd/session.c b/source3/smbd/session.c index 15154162b9..69f4a37c85 100644 --- a/source3/smbd/session.c +++ b/source3/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/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c index 35efbc009f..87cb3b435b 100644 --- a/source3/smbd/sesssetup.c +++ b/source3/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/source3/web/cgi.c b/source3/web/cgi.c index 71328459f0..41ac29be5d 100644 --- a/source3/web/cgi.c +++ b/source3/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"); } |