All of lore.kernel.org
 help / color / mirror / Atom feed
From: t.feng <fengtao40@huawei.com>
To: <grub-devel@gnu.org>
Cc: <fengtao40@huawei.com>, <daniel.kiper@oracle.com>,
	<yanan@huawei.com>, <zhaowei23@huawei.com>
Subject: [PATCH 6/9] fs/hfsplus: Fix memory leak in grub_hfsplus_btree_search
Date: Sat, 19 Nov 2022 18:39:43 +0800	[thread overview]
Message-ID: <20221119103946.657744-7-fengtao40@huawei.com> (raw)
In-Reply-To: <20221119103946.657744-1-fengtao40@huawei.com>

Fix memory leak in grub_hfsplus_btree_search.

Fixes: 58ea11d5b(Don't fetch a key beyond the end of the node)

Signed-off-by: "t.feng" <fengtao40@huawei.com>
---
 grub-core/fs/hfsplus.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c
index 6337cbfcb..11393ca34 100644
--- a/grub-core/fs/hfsplus.c
+++ b/grub-core/fs/hfsplus.c
@@ -652,7 +652,10 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
 			 + 2);
 
 	      if ((char *) pointer > node + btree->nodesize - 2)
-		return grub_error (GRUB_ERR_BAD_FS, "HFS+ key beyond end of node");
+	        {
+	          grub_free (node);
+	          return grub_error (GRUB_ERR_BAD_FS, "HFS+ key beyond end of node");
+	        }
 
 	      currnode = grub_be_to_cpu32 (grub_get_unaligned32 (pointer));
 	      match = 1;
-- 
2.27.0



  parent reply	other threads:[~2022-11-19 10:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-19 10:39 [PATCH 0/9] fix memory leaks in fs module t.feng
2022-11-19 10:39 ` [PATCH 1/9] fs/affs:Fix memory leaks in grub_affs_create_node t.feng
2022-11-19 10:39 ` [PATCH 2/9] fs/btrfs: Fix memory leak in find_path t.feng
2022-11-19 10:39 ` [PATCH 3/9] fs/minix: Fix memory leak in grub_minix_lookup_symlink t.feng
2022-11-23 15:10   ` Daniel Kiper
2022-11-19 10:39 ` [PATCH 4/9] fs/ntfs: Fix memory leak in grub_ntfs_read_symlink t.feng
2022-11-23 15:16   ` Daniel Kiper
2022-11-19 10:39 ` [PATCH 5/9] fs/bfs: Fix memory leak in read_bfs_file t.feng
2022-11-19 10:39 ` t.feng [this message]
2022-11-19 10:39 ` [PATCH 7/9] fs/iso9660: Fix memory leak in grub_iso9660_susp_iterate t.feng
2022-11-19 12:26   ` Thomas Schmitt
2022-11-19 10:39 ` [PATCH 8/9] fs/squash4: Fix memeory leak in grub_squash_iterate_dir t.feng
2022-11-19 10:39 ` [PATCH 9/9] fs/xfs: Fix memory leaks in xfs t.feng
2022-11-23 15:37 ` [PATCH 0/9] fix memory leaks in fs module Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221119103946.657744-7-fengtao40@huawei.com \
    --to=fengtao40@huawei.com \
    --cc=daniel.kiper@oracle.com \
    --cc=grub-devel@gnu.org \
    --cc=yanan@huawei.com \
    --cc=zhaowei23@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.