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