mirror of
https://github.com/samba-team/samba.git
synced 2025-03-12 20:58:37 +03:00
s3:modules:recycle - fix crash in recycle_unlink_internal
Original logic for separating path from base name assumed that we were using same string to determine offset when getting the parent dir name (smb_fname->base_name). Simplify by using parent_dirname() to split the path from base name. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14888 Signed-off-by: Andrew Walker <awalker@ixsystems.com> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sat Oct 30 04:34:53 UTC 2021 on sn-devel-184 (cherry picked from commit be3a47e22ad6be204f4a7d6070f82f990c17e6fb)
This commit is contained in:
parent
9bcba58e4d
commit
4d68d797f1
@ -572,17 +572,10 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
|
||||
*/
|
||||
|
||||
/* extract filename and path */
|
||||
base = strrchr(full_fname->base_name, '/');
|
||||
if (base == NULL) {
|
||||
base = full_fname->base_name;
|
||||
path_name = SMB_STRDUP("/");
|
||||
ALLOC_CHECK(path_name, done);
|
||||
}
|
||||
else {
|
||||
path_name = SMB_STRDUP(full_fname->base_name);
|
||||
ALLOC_CHECK(path_name, done);
|
||||
path_name[base - smb_fname->base_name] = '\0';
|
||||
base++;
|
||||
if (!parent_dirname(talloc_tos(), full_fname->base_name, &path_name, &base)) {
|
||||
rc = -1;
|
||||
errno = ENOMEM;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* original filename with path */
|
||||
@ -717,7 +710,7 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
|
||||
recycle_touch_mtime(handle));
|
||||
|
||||
done:
|
||||
SAFE_FREE(path_name);
|
||||
TALLOC_FREE(path_name);
|
||||
SAFE_FREE(temp_name);
|
||||
SAFE_FREE(final_name);
|
||||
TALLOC_FREE(full_fname);
|
||||
|
Loading…
x
Reference in New Issue
Block a user