[PATCH] s3: Fix possible mem leak

Swen Schillig swen at vnet.ibm.com
Tue Mar 6 10:47:28 UTC 2018


Please review ....and push.

Thanks in advance.

Cheers Swen
-------------- next part --------------
From d7d9623be7dbbc0b1e956336ed536de9b1346933 Mon Sep 17 00:00:00 2001
From: Swen Schillig <swen at vnet.ibm.com>
Date: Tue, 6 Mar 2018 10:35:32 +0100
Subject: [PATCH] s3: Fix possible mem leak

The call to full_path_tos() might allocate memory which needs to be free'd
once processign is done.

Signed-off-by: Swen Schillig <swen at vnet.ibm.com>
---
 source3/smbd/dir.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index eba1fbb5db5..479709aec40 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -2027,24 +2027,29 @@ static int files_below_forall_fn(struct file_id fid,
 		/*
 		 * Filter files above dirpath
 		 */
-		return 0;
+		goto err_out;
 	}
 	if (fullpath[state->dirpath_len] != '/') {
 		/*
 		 * Filter file that don't have a path separator at the end of
 		 * dirpath's length
 		 */
-		return 0;
+		goto err_out;
 	}
 
 	if (memcmp(state->dirpath, fullpath, state->dirpath_len) != 0) {
 		/*
 		 * Not a parent
 		 */
-		return 0;
+		goto err_out;
 	}
 
+	talloc_free(to_free);
 	return state->fn(fid, data, state->private_data);
+
+err_out:
+	talloc_free(to_free);
+	return 0;
 }
 
 static int files_below_forall(connection_struct *conn,
-- 
2.14.3



More information about the samba-technical mailing list