From 62c3a7a6bd165e10d58acad57858901c699ae470 Mon Sep 17 00:00:00 2001 From: Swen Schillig 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 Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison --- 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 4480ec38882..2ed71752977 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -2028,24 +2028,29 @@ static int files_below_forall_fn(struct file_id fid, /* * Filter files above dirpath */ - return 0; + goto 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 out; } if (memcmp(state->dirpath, fullpath, state->dirpath_len) != 0) { /* * Not a parent */ - return 0; + goto out; } + TALLOC_FREE(to_free); return state->fn(fid, data, state->private_data); + +out: + TALLOC_FREE(to_free); + return 0; } static int files_below_forall(connection_struct *conn, -- 2.11.4.GIT