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 4480ec3..2ed7175 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,