Ticket #4561: tar: fix segault on copy fiiles from archive.

* (tar_read_header): canonicalize path name after decoding of all
    headers occupied with long file/directory name.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2024-07-12 20:26:41 +03:00
parent b68243df1e
commit ffdb057e5b

View File

@ -773,7 +773,6 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive)
} }
tar_assign_string_dup (&current_stat_info.orig_file_name, file_name); tar_assign_string_dup (&current_stat_info.orig_file_name, file_name);
canonicalize_pathname (file_name);
tar_assign_string (&current_stat_info.file_name, file_name); tar_assign_string (&current_stat_info.file_name, file_name);
g_free (recent_long_link); g_free (recent_long_link);
@ -817,6 +816,9 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive)
current_stat_info.is_dumpdir = TRUE; current_stat_info.is_dumpdir = TRUE;
} }
/* Do this after decoding of all headers occupied with long file/directory name. */
canonicalize_pathname (current_stat_info.file_name);
status = tar_insert_entry (me, archive, header, &inode); status = tar_insert_entry (me, archive, header, &inode);
if (status != HEADER_SUCCESS) if (status != HEADER_SUCCESS)
{ {