s3: Fix possible mem leak
authorSwen Schillig <swen@vnet.ibm.com>
Tue, 6 Mar 2018 09:35:32 +0000 (10:35 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 20 Mar 2018 22:16:14 +0000 (23:16 +0100)
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@vnet.ibm.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/dir.c

index 4480ec38882161864c97380b87afb62a243a72b1..2ed71752977a7d8e4d494cac33470f40f1bb7226 100644 (file)
@@ -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,