mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
Fix a really slow memory leak (in master at least). Found by Ira Cooper <ira@wakeful.net>.
Bug #8724 - Memory leak in parent smbd on connection. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Fri Jan 27 01:26:28 CET 2012 on sn-devel-104
This commit is contained in:
parent
633a28b276
commit
17a77ea9b4
@ -195,7 +195,7 @@ void sub_set_smb_name(const char *name)
|
||||
}
|
||||
|
||||
static char sub_peeraddr[INET6_ADDRSTRLEN];
|
||||
static const char *sub_peername = "";
|
||||
static const char *sub_peername = NULL;
|
||||
static char sub_sockaddr[INET6_ADDRSTRLEN];
|
||||
|
||||
void sub_set_socket_ids(const char *peeraddr, const char *peername,
|
||||
@ -208,6 +208,11 @@ void sub_set_socket_ids(const char *peeraddr, const char *peername,
|
||||
}
|
||||
strlcpy(sub_peeraddr, addr, sizeof(sub_peeraddr));
|
||||
|
||||
if (sub_peername != NULL &&
|
||||
sub_peername != sub_peeraddr) {
|
||||
free(discard_const_p(char,sub_peername));
|
||||
sub_peername = NULL;
|
||||
}
|
||||
sub_peername = SMB_STRDUP(peername);
|
||||
if (sub_peername == NULL) {
|
||||
sub_peername = sub_peeraddr;
|
||||
@ -547,7 +552,7 @@ static char *alloc_sub_basic(const char *smb_name, const char *domain_name,
|
||||
break;
|
||||
case 'M' :
|
||||
a_string = realloc_string_sub(a_string, "%M",
|
||||
sub_peername);
|
||||
sub_peername ? sub_peername : "");
|
||||
break;
|
||||
case 'R' :
|
||||
a_string = realloc_string_sub(a_string, "%R", remote_proto);
|
||||
|
Loading…
Reference in New Issue
Block a user