diff options
author | Gerald Carter <jerry@samba.org> | 2004-02-10 04:04:24 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2004-02-10 04:04:24 +0000 |
commit | c2d30222c6d9f2068ffd5835a0b45d35378d72e1 (patch) | |
tree | 4dc7309a3cb223b3a81b8f83513660ef16c899b9 /source3/lib | |
parent | ffce0e466642134bd4556a91310761630400ed03 (diff) | |
download | samba-c2d30222c6d9f2068ffd5835a0b45d35378d72e1.tar.gz samba-c2d30222c6d9f2068ffd5835a0b45d35378d72e1.tar.bz2 samba-c2d30222c6d9f2068ffd5835a0b45d35378d72e1.zip |
merge fixes from 3.0
(This used to be commit ea75f34eef90e410045fe4d32052cbea483a27da)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_sock.c | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 12c748e5f2..782f5f3f73 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -29,6 +29,29 @@ int lastport=0; int smb_read_error = 0; +static char *get_socket_addr(int fd) +{ + struct sockaddr sa; + struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa); + int length = sizeof(sa); + static fstring addr_buf; + + fstrcpy(addr_buf,"0.0.0.0"); + + if (fd == -1) { + return addr_buf; + } + + if (getsockname(fd, &sa, &length) < 0) { + DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) )); + return addr_buf; + } + + fstrcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr)); + + return addr_buf; +} + /**************************************************************************** Determine if a file descriptor is in fact a socket. ****************************************************************************/ @@ -552,6 +575,10 @@ BOOL receive_smb_raw(int fd,char *buffer, unsigned int timeout) smb_read_error = READ_ERROR; return False; } + + /* not all of samba3 properly checks for packet-termination of strings. This + ensures that we don't run off into empty space. */ + SSVAL(buffer+4,len, 0); } return True; @@ -954,29 +981,6 @@ char *get_peer_addr(int fd) return addr_buf; } -static char *get_socket_addr(int fd) -{ - struct sockaddr sa; - struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa); - int length = sizeof(sa); - static fstring addr_buf; - - fstrcpy(addr_buf,"0.0.0.0"); - - if (fd == -1) { - return addr_buf; - } - - if (getsockname(fd, &sa, &length) < 0) { - DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) )); - return addr_buf; - } - - fstrcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr)); - - return addr_buf; -} - /******************************************************************* Create protected unix domain socket. |