The branch, master has been updated
       via  86a80cf Fix bug 8823 - source3/smbd/process.c:smb_dump seems to 
have a memory leak.
      from  217d041 s4-samba-tool: add password verification in change user pass

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 86a80cf4fde13576ed89a5e1ea12bb5e61261fc8
Author: Jeremy Allison <[email protected]>
Date:   Wed Mar 21 14:34:34 2012 -0700

    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 <[email protected]>
    Autobuild-Date: Thu Mar 22 00:20:41 CET 2012 on sn-devel-104

-----------------------------------------------------------------------

Summary of changes:
 source3/smbd/process.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 8b15ac8..defedf6 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);
 }
 
 /****************************************************************************


-- 
Samba Shared Repository

Reply via email to