diff options
author | Gerald Carter <jerry@samba.org> | 2003-12-09 18:20:27 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2003-12-09 18:20:27 +0000 |
commit | e25b7b8eed38942dc8daaff3b7273c1c60fe82f0 (patch) | |
tree | e91d00a4e37248ced388afbaf5be24a4f07298fc | |
parent | f9876dbe28c0df47a94b13d85447f4ab6bb7a8ad (diff) | |
download | samba-e25b7b8eed38942dc8daaff3b7273c1c60fe82f0.tar.gz samba-e25b7b8eed38942dc8daaff3b7273c1c60fe82f0.tar.bz2 samba-e25b7b8eed38942dc8daaff3b7273c1c60fe82f0.zip |
fix bug in get_peer_name() caused by --enable-developer and using the same src & dest strings to alpha_strcpy(); reported by Michael Young
(This used to be commit b7df6849c9368aa2e5960de54a03be269ab89fef)
-rw-r--r-- | source3/lib/util_sock.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 1d62da53c5..328ca92727 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -874,6 +874,7 @@ static BOOL matchname(char *remotehost,struct in_addr addr) char *get_peer_name(int fd, BOOL force_lookup) { static pstring name_buf; + pstring tmp_name; static fstring addr_buf; struct hostent *hp; struct in_addr addr; @@ -890,10 +891,12 @@ char *get_peer_name(int fd, BOOL force_lookup) p = get_peer_addr(fd); /* it might be the same as the last one - save some DNS work */ - if (strcmp(p, addr_buf) == 0) return name_buf; + if (strcmp(p, addr_buf) == 0) + return name_buf; pstrcpy(name_buf,"UNKNOWN"); - if (fd == -1) return name_buf; + if (fd == -1) + return name_buf; fstrcpy(addr_buf, p); @@ -911,7 +914,12 @@ char *get_peer_name(int fd, BOOL force_lookup) } } - alpha_strcpy(name_buf, name_buf, "_-.", sizeof(name_buf)); + /* can't pass the same source and dest strings in when you + use --enable-developer or the clobber_region() call will + get you */ + + pstrcpy( tmp_name, name_buf ); + alpha_strcpy(name_buf, tmp_name, "_-.", sizeof(name_buf)); if (strstr(name_buf,"..")) { pstrcpy(name_buf, "UNKNOWN"); } |