]> git.ipfire.org Git - thirdparty/grub.git/commit
fs/iso9660: Fix invalid free
authorMichael Chang <mchang@suse.com>
Fri, 31 May 2024 07:14:42 +0000 (15:14 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 23 Jan 2025 15:22:46 +0000 (16:22 +0100)
commit1443833a9535a5873f7de3798cf4d8389f366611
treeff5dac29519bfe744cede51a8c817d2337c771b3
parent965db5970811d18069b34f28f5f31ddadde90a97
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>
grub-core/fs/iso9660.c