Skip to content

Commit bbdf041

Browse files
committed
fix: double free of the new name on a late rename failure
After the destination name buffers are assigned to fromdentry, a later failure (e.g. fs_add_key_to_hash_table) reached out_free, which freed those same buffers because ret < 0 — leaving fromdentry with dangling name/platform_safe_name pointers that are freed again when the dentry is disposed. Clear the locals once ownership moves to fromdentry.
1 parent e379b4e commit bbdf041

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/libltfs/ltfs_fsops.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,10 @@ int ltfs_fsops_rename(const char *from, const char *to, ltfs_file_id *id, struct
868868
fromdentry->name.percent_encode = fs_is_percent_encode_required(fromdentry->name.name);
869869
fromdentry->platform_safe_name = to_filename_copy2;
870870
fromdentry->matches_name_criteria = index_criteria_match(fromdentry, vol);
871+
/* Ownership of both buffers has moved to fromdentry; clear the locals so
872+
* the out_free path does not free them again if a later step fails. */
873+
to_filename_copy = NULL;
874+
to_filename_copy2 = NULL;
871875

872876
/* Add fromdentry to new directory */
873877
todir->child_list = fs_add_key_to_hash_table(todir->child_list, fromdentry, &ret);

0 commit comments

Comments
 (0)