From 6b0707cfa244b2ff1565e92a41a21a903f689e7d Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Thu, 9 Nov 2023 16:42:20 +0100 Subject: [PATCH] TFTP Fix critical error in open implementation --- project/Core/Src/tftp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/project/Core/Src/tftp.c b/project/Core/Src/tftp.c index 44adf2c..532a5d6 100644 --- a/project/Core/Src/tftp.c +++ b/project/Core/Src/tftp.c @@ -34,13 +34,12 @@ void* tftp_open(const char* fname, const char* mode, u8_t write) { llfs_file_t* file; if (strcmp(fname, virt_file[0].name) == 0 && write == TFTP_READ) { - file = &virt_file[0]; + return &virt_file[0]; } else if (strcmp(fname, virt_file[1].name) == 0 && write != TFTP_READ) { - file = &virt_file[1]; + return &virt_file[1]; } - file = llfs_file_open(fname); - return file; + return llfs_file_open(fname); } /** @@ -54,6 +53,8 @@ void tftp_close(void* handle) { /** * @brief This function is called when a file is read + * The virtual files are filtered out first + * then the file is trying to get read from the llfs * * @param handle File handle returned by open() * @param buf Target buffer to copy read data to