diff options
author | Jeremy Allison <jra@samba.org> | 2012-03-21 14:34:34 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2012-03-22 00:20:40 +0100 |
commit | 86a80cf4fde13576ed89a5e1ea12bb5e61261fc8 (patch) | |
tree | 98538953ff913bdfdc82961813fbc81d36ec592c | |
parent | 217d04138b9ba13ca30ea9d826e6b515d9e593dc (diff) | |
download | samba-86a80cf4fde13576ed89a5e1ea12bb5e61261fc8.tar.gz samba-86a80cf4fde13576ed89a5e1ea12bb5e61261fc8.tar.bz2 samba-86a80cf4fde13576ed89a5e1ea12bb5e61261fc8.zip |
Fix bug 8823 - source3/smbd/process.c:smb_dump seems to have a memory leak.
Based on code from Richard Sharpe. Move to talloc from malloc.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Thu Mar 22 00:20:41 CET 2012 on sn-devel-104
-rw-r--r-- | source3/smbd/process.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 8b15ac88f9..defedf6d6c 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -1315,12 +1315,17 @@ static void smb_dump(const char *name, int type, const char *data) len = smb_len_tcp(data)+4; for (i=1;i<100;i++) { - if (asprintf(&fname, "/tmp/%s.%d.%s", name, i, - type ? "req" : "resp") == -1) { + fname = talloc_asprintf(talloc_tos(), + "/tmp/%s.%d.%s", + name, + i, + type ? "req" : "resp"); + if (fname == NULL) { return; } fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644); if (fd != -1 || errno != EEXIST) break; + TALLOC_FREE(fname); } if (fd != -1) { ssize_t ret = write(fd, data, len); @@ -1329,7 +1334,7 @@ static void smb_dump(const char *name, int type, const char *data) close(fd); DEBUG(0,("created %s len %lu\n", fname, (unsigned long)len)); } - SAFE_FREE(fname); + TALLOC_FREE(fname); } /**************************************************************************** |