Skip to content

Commit

Permalink
Ticket #4616: (tar_read_header): fix double free.
Browse files Browse the repository at this point in the history
When tar data block unexpected end then header_copy get freed but
"goto ret:" freed header_copy again.

Do not free header_copy at exit from the loop of reading tar blocks.

Found by Clang-19 Static Analyzer.

The bug was introduced in 8223f82.

Reported-by: Andreas Mohr <[email protected]>
Signed-off-by: Andrew Borodin <[email protected]>
  • Loading branch information
aborodin committed Dec 21, 2024
1 parent d205be6 commit 152362b
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/vfs/tar/tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive)
data_block = tar_find_next_block (arch);
if (data_block == NULL)
{
g_free (header_copy);
message (D_ERROR, MSG_ERROR, _("Unexpected EOF on archive file"));
status = HEADER_FAILURE;
goto ret;
Expand Down

0 comments on commit 152362b

Please sign in to comment.