]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
net/tftp: Fix dangling memory pointer
authorDarren Kenny <darren.kenny@oracle.com>
Fri, 19 Feb 2021 17:12:23 +0000 (17:12 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 2 Mar 2021 14:54:16 +0000 (15:54 +0100)
The static code analysis tool, Parfait, reported that the valid of
file->data was left referencing memory that was freed by the call to
grub_free(data) where data was initialized from file->data.

To ensure that there is no unintentional access to this memory
referenced by file->data we should set the pointer to NULL.

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/net/tftp.c

index 7e659a78b0ede80f7f751fd0fc9e20c085d19729..1f3793ed8c14cb332d4485352657b3a6b3b7a822 100644 (file)
@@ -442,6 +442,7 @@ tftp_close (struct grub_file *file)
       grub_net_udp_close (data->sock);
     }
   grub_free (data);
+  file->data = NULL;
   return GRUB_ERR_NONE;
 }