nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0310-udf-Fix-memory-leak.patch

c4e390
From 7ba278675832c85846faa7191a958a84cb7ace11 Mon Sep 17 00:00:00 2001
c4e390
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
c4e390
Date: Tue, 7 Jul 2020 22:02:31 -0400
c4e390
Subject: [PATCH 310/336] udf: Fix memory leak
c4e390
c4e390
Fixes: CID 73796
c4e390
c4e390
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
c4e390
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
c4e390
Reviewed-by: Jan Setje-Eilers <jan.setjeeilers@oracle.com>
c4e390
Upstream-commit-id: 8da62d8183c
c4e390
---
c4e390
 grub-core/fs/udf.c | 17 +++++++++++++----
c4e390
 1 file changed, 13 insertions(+), 4 deletions(-)
c4e390
c4e390
diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c
c4e390
index 99b001f2066..c23c0120f49 100644
c4e390
--- a/grub-core/fs/udf.c
c4e390
+++ b/grub-core/fs/udf.c
c4e390
@@ -909,8 +909,10 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
c4e390
 	    return 0;
c4e390
 
c4e390
           if (grub_udf_read_icb (dir->data, &dirent.icb, child))
c4e390
-	    return 0;
c4e390
-
c4e390
+	    {
c4e390
+	      grub_free (child);
c4e390
+	      return 0;
c4e390
+	    }
c4e390
           if (dirent.characteristics & GRUB_UDF_FID_CHAR_PARENT)
c4e390
 	    {
c4e390
 	      /* This is the parent directory.  */
c4e390
@@ -932,11 +934,18 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
c4e390
 				       dirent.file_ident_length,
c4e390
 				       (char *) raw))
c4e390
 		  != dirent.file_ident_length)
c4e390
-		return 0;
c4e390
+		{
c4e390
+		  grub_free (child);
c4e390
+		  return 0;
c4e390
+		}
c4e390
 
c4e390
 	      filename = read_string (raw, dirent.file_ident_length, 0);
c4e390
 	      if (!filename)
c4e390
-		grub_print_error ();
c4e390
+		{
c4e390
+		  /* As the hook won't get called. */
c4e390
+		  grub_free (child);
c4e390
+		  grub_print_error ();
c4e390
+		}
c4e390
 
c4e390
 	      if (filename && hook (filename, type, child, hook_data))
c4e390
 		{
c4e390
-- 
c4e390
2.26.2
c4e390