From 40997c4a080f94148d06c41a9607536267efef15 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Mon, 29 Jan 2018 06:59:47 +0100 Subject: [PATCH] Apply (modified) patch #9552: tftp_cleanup() for cleanup and filename buffer zeroing to prevent filename bugs ... without the memset to zero out the filename --- src/apps/tftp/tftp_server.c | 10 ++++++++++ src/include/lwip/apps/tftp_server.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/apps/tftp/tftp_server.c b/src/apps/tftp/tftp_server.c index 6da94d48..07f6170e 100644 --- a/src/apps/tftp/tftp_server.c +++ b/src/apps/tftp/tftp_server.c @@ -412,4 +412,14 @@ tftp_init(const struct tftp_context *ctx) return ERR_OK; } +/** @ingroup tftp + * Deinitialize ("turn off") TFTP server. + */ +void tftp_cleanup(void) +{ + LWIP_ASSERT("Cleanup called on non-initialized TFTP", tftp_state.upcb != NULL); + udp_remove(tftp_state.upcb); + memset(&tftp_state, 0, sizeof(tftp_state)); +} + #endif /* LWIP_UDP */ diff --git a/src/include/lwip/apps/tftp_server.h b/src/include/lwip/apps/tftp_server.h index a27ed961..0a7fbee0 100644 --- a/src/include/lwip/apps/tftp_server.h +++ b/src/include/lwip/apps/tftp_server.h @@ -86,6 +86,7 @@ struct tftp_context { }; err_t tftp_init(const struct tftp_context* ctx); +void tftp_cleanup(void); #ifdef __cplusplus }