nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0452-io-gzio-Zero-gzio-tl-td-in-init_dynamic_block-if-huf.patch

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