xref: /OK3568_Linux_fs/buildroot/boot/grub2/0013-udf-Fix-memory-leak.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 748b691761d31bfff7e9d0d210caa606294c2b52 Mon Sep 17 00:00:00 2001
2From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
3Date: Tue, 7 Jul 2020 22:02:31 -0400
4Subject: [PATCH] udf: Fix memory leak
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Fixes: CID 73796
10
11Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
12Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
13Reviewed-by: Jan Setje-Eilers <jan.setjeeilers@oracle.com>
14Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
15---
16 grub-core/fs/udf.c | 17 +++++++++++++----
17 1 file changed, 13 insertions(+), 4 deletions(-)
18
19diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c
20index 21ac7f446..2ac5c1d00 100644
21--- a/grub-core/fs/udf.c
22+++ b/grub-core/fs/udf.c
23@@ -965,8 +965,10 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
24 	    return 0;
25
26           if (grub_udf_read_icb (dir->data, &dirent.icb, child))
27-	    return 0;
28-
29+	    {
30+	      grub_free (child);
31+	      return 0;
32+	    }
33           if (dirent.characteristics & GRUB_UDF_FID_CHAR_PARENT)
34 	    {
35 	      /* This is the parent directory.  */
36@@ -988,11 +990,18 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
37 				       dirent.file_ident_length,
38 				       (char *) raw))
39 		  != dirent.file_ident_length)
40-		return 0;
41+		{
42+		  grub_free (child);
43+		  return 0;
44+		}
45
46 	      filename = read_string (raw, dirent.file_ident_length, 0);
47 	      if (!filename)
48-		grub_print_error ();
49+		{
50+		  /* As the hook won't get called. */
51+		  grub_free (child);
52+		  grub_print_error ();
53+		}
54
55 	      if (filename && hook (filename, type, child, hook_data))
56 		{
57--
582.26.2
59
60