fs/iso9660: Fix invalid free
authorMichael Chang <mchang@suse.com>
Fri, 31 May 2024 07:14:42 +0000 (15:14 +0800)
committerFelix Zielcke <fzielcke@z-51.de>
Wed, 11 Jun 2025 15:42:34 +0000 (17:42 +0200)
commitd82b41f4e935f930419a706130def0d497a0f32b
tree22b7b6fb7b28f2f7041ba2feb38a2c50f068e0f5
parentbc955a3f1da7ab22ad0c915ae5d1a5012115f8db
fs/iso9660: Fix invalid free

The ctx->filename can point to either a string literal or a dynamically
allocated string. The ctx->filename_alloc field is used to indicate the
type of allocation.

An issue has been identified where ctx->filename is reassigned to
a string literal in susp_iterate_dir() but ctx->filename_alloc is not
correctly handled. This oversight causes a memory leak and an invalid
free operation later.

The fix involves checking ctx->filename_alloc, freeing the allocated
string if necessary and clearing ctx->filename_alloc for string literals.

Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name fs-iso9660-Fix-invalid-free.patch
grub-core/fs/iso9660.c