0051-net-tftp-Fix-dangling-memory-pointer.patch 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. From 0cb838b281a68b536a09681f9557ea6a7ac5da7a Mon Sep 17 00:00:00 2001
  2. From: Darren Kenny <darren.kenny@oracle.com>
  3. Date: Fri, 19 Feb 2021 17:12:23 +0000
  4. Subject: [PATCH] net/tftp: Fix dangling memory pointer
  5. The static code analysis tool, Parfait, reported that the valid of
  6. file->data was left referencing memory that was freed by the call to
  7. grub_free(data) where data was initialized from file->data.
  8. To ensure that there is no unintentional access to this memory
  9. referenced by file->data we should set the pointer to NULL.
  10. Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
  11. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  12. Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
  13. ---
  14. grub-core/net/tftp.c | 1 +
  15. 1 file changed, 1 insertion(+)
  16. diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c
  17. index b4297bc..c106704 100644
  18. --- a/grub-core/net/tftp.c
  19. +++ b/grub-core/net/tftp.c
  20. @@ -406,6 +406,7 @@ tftp_close (struct grub_file *file)
  21. grub_net_udp_close (data->sock);
  22. }
  23. grub_free (data);
  24. + file->data = NULL;
  25. return GRUB_ERR_NONE;
  26. }
  27. --
  28. 2.14.2