dcavalca / rpms / grub2

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