|
|
9723a8 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
9723a8 |
From: Daniel Axtens <dja@axtens.net>
|
|
|
9723a8 |
Date: Thu, 21 Jan 2021 12:22:28 +1100
|
|
|
9723a8 |
Subject: [PATCH] io/gzio: Zero gzio->tl/td in init_dynamic_block() if
|
|
|
9723a8 |
huft_build() fails
|
|
|
9723a8 |
|
|
|
9723a8 |
If huft_build() fails, gzio->tl or gzio->td could contain pointers that
|
|
|
9723a8 |
are no longer valid. Zero them out.
|
|
|
9723a8 |
|
|
|
9723a8 |
This prevents a double free when grub_gzio_close() comes through and
|
|
|
9723a8 |
attempts to free them again.
|
|
|
9723a8 |
|
|
|
9723a8 |
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
|
9723a8 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
9723a8 |
---
|
|
|
9723a8 |
grub-core/io/gzio.c | 2 ++
|
|
|
9723a8 |
1 file changed, 2 insertions(+)
|
|
|
9723a8 |
|
|
|
9723a8 |
diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c
|
|
|
9723a8 |
index fa7d9990b84..81d658818be 100644
|
|
|
9723a8 |
--- a/grub-core/io/gzio.c
|
|
|
9723a8 |
+++ b/grub-core/io/gzio.c
|
|
|
9723a8 |
@@ -1010,6 +1010,7 @@ init_dynamic_block (grub_gzio_t gzio)
|
|
|
9723a8 |
gzio->bl = lbits;
|
|
|
9723a8 |
if (huft_build (ll, nl, 257, cplens, cplext, &gzio->tl, &gzio->bl) != 0)
|
|
|
9723a8 |
{
|
|
|
9723a8 |
+ gzio->tl = 0;
|
|
|
9723a8 |
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
|
|
|
9723a8 |
"failed in building a Huffman code table");
|
|
|
9723a8 |
return;
|
|
|
9723a8 |
@@ -1019,6 +1020,7 @@ init_dynamic_block (grub_gzio_t gzio)
|
|
|
9723a8 |
{
|
|
|
9723a8 |
huft_free (gzio->tl);
|
|
|
9723a8 |
gzio->tl = 0;
|
|
|
9723a8 |
+ gzio->td = 0;
|
|
|
9723a8 |
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA,
|
|
|
9723a8 |
"failed in building a Huffman code table");
|
|
|
9723a8 |
return;
|