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