Bug 8823 - source3/smbd/process.c:smb_dump seems to have a memory leak
source3/smbd/process.c:smb_dump seems to have a memory leak
Product: Samba 3.6
Classification: Unclassified
Component: File services
All All
: P5 normal
: ---
Assigned To: Volker Lendecke
Samba QA Contact
Depends on:
  Show dependency treegraph
Reported: 2012-03-21 21:00 UTC by Richard Sharpe
Modified: 2012-05-10 08:45 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Richard Sharpe 2012-03-21 21:00:45 UTC
This problem was found by one of the engineers looking at problems.

The fix appears to be:

diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 8b15ac8..66fe5ef 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -1321,6 +1321,7 @@ static void smb_dump(const char *name, int type, const cha
                fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644);
                if (fd != -1 || errno != EEXIST) break;
+               SAFE_FREE(fname);
        if (fd != -1) {
                ssize_t ret = write(fd, data, len);
Comment 1 Richard Sharpe 2012-03-22 13:43:40 UTC
This seems like such an obvious thing that I will push a fix for this today.
Comment 2 Richard Sharpe 2012-03-22 13:45:32 UTC
Except, it is already fixed ... at least master.
Comment 3 Richard Sharpe 2012-03-22 13:50:57 UTC
OK, I see. Jeremy fixed it yesterday. I agree with the move to talloc.

To complete the attributions, the problem was found by Shyam Vanga at Dell/Ocarina when QA reported a crash.
Comment 4 Richard Sharpe 2012-05-10 08:45:29 UTC
Fixed in this commit:

commit 86a80cf4fde13576ed89a5e1ea12bb5e61261fc8
Author: Jeremy Allison <jra@samba.org>
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 <jra@samba.org>
    Autobuild-Date: Thu Mar 22 00:20:41 CET 2012 on sn-devel-104