0075-syslinux-Fix-memory-leak-while-parsing.patch 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. From 95bc016dba94cab3d398dd74160665915cd08ad6 Mon Sep 17 00:00:00 2001
  2. From: Darren Kenny <darren.kenny@oracle.com>
  3. Date: Thu, 26 Nov 2020 15:31:53 +0000
  4. Subject: [PATCH] syslinux: Fix memory leak while parsing
  5. In syslinux_parse_real() the 2 points where return is being called
  6. didn't release the memory stored in buf which is no longer required.
  7. Fixes: CID 176634
  8. Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
  9. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  10. Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
  11. ---
  12. grub-core/lib/syslinux_parse.c | 6 +++++-
  13. 1 file changed, 5 insertions(+), 1 deletion(-)
  14. diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c
  15. index 4afa992..3acc6b4 100644
  16. --- a/grub-core/lib/syslinux_parse.c
  17. +++ b/grub-core/lib/syslinux_parse.c
  18. @@ -737,7 +737,10 @@ syslinux_parse_real (struct syslinux_menu *menu)
  19. && grub_strncasecmp ("help", ptr3, ptr4 - ptr3) == 0))
  20. {
  21. if (helptext (ptr5, file, menu))
  22. - return 1;
  23. + {
  24. + grub_free (buf);
  25. + return 1;
  26. + }
  27. continue;
  28. }
  29. @@ -757,6 +760,7 @@ syslinux_parse_real (struct syslinux_menu *menu)
  30. }
  31. fail:
  32. grub_file_close (file);
  33. + grub_free (buf);
  34. return err;
  35. }
  36. --
  37. 2.14.2