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