dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0412-syslinux-Fix-memory-leak-while-parsing.patch

468bd4
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
468bd4
From: Darren Kenny <darren.kenny@oracle.com>
468bd4
Date: Thu, 26 Nov 2020 15:31:53 +0000
468bd4
Subject: [PATCH] syslinux: Fix memory leak while parsing
468bd4
468bd4
In syslinux_parse_real() the 2 points where return is being called
468bd4
didn't release the memory stored in buf which is no longer required.
468bd4
468bd4
Fixes: CID 176634
468bd4
468bd4
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
468bd4
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
468bd4
---
468bd4
 grub-core/lib/syslinux_parse.c | 6 +++++-
468bd4
 1 file changed, 5 insertions(+), 1 deletion(-)
468bd4
468bd4
diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c
468bd4
index 83e7bdb9161..f477feff1c3 100644
468bd4
--- a/grub-core/lib/syslinux_parse.c
468bd4
+++ b/grub-core/lib/syslinux_parse.c
468bd4
@@ -737,7 +737,10 @@ syslinux_parse_real (struct syslinux_menu *menu)
468bd4
 		  && grub_strncasecmp ("help", ptr3, ptr4 - ptr3) == 0))
468bd4
 	    {
468bd4
 	      if (helptext (ptr5, file, menu))
468bd4
-		return 1;
468bd4
+		{
468bd4
+		  grub_free (buf);
468bd4
+		  return 1;
468bd4
+		}
468bd4
 	      continue;
468bd4
 	    }
468bd4
 
468bd4
@@ -757,6 +760,7 @@ syslinux_parse_real (struct syslinux_menu *menu)
468bd4
     }
468bd4
  fail:
468bd4
   grub_file_close (file);
468bd4
+  grub_free (buf);
468bd4
   return err;
468bd4
 }
468bd4