diff options
author | Jerome Forissier <jerome.forissier@linaro.org> | 2024-10-16 12:04:04 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-10-16 11:11:56 -0600 |
commit | 5634ecc88e9fc9bd1bd422861ee4d9dbac851b32 (patch) | |
tree | abaa9ae753ee1e1dfe6dc72e35b10681b1b035f1 | |
parent | 98ad145db61a51308abb9de3212d4e3078d145c0 (diff) |
net: lwip: tftp: bind to TFTP port only when in server mode
The TFTP app should not bind to the TFTP server port when configured as
a client. Instead, the local port should be chosen from the dynamic
range (49152 ~ 65535) so that if the application is stopped and started
again, the remote server will not consider the new packets as part of
the same context (which would cause an error since a new RRQ would be
unexpected).
Submitted upstream: https://savannah.nongnu.org/patch/?10480
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
-rw-r--r-- | lib/lwip/lwip/src/apps/tftp/tftp.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/lwip/lwip/src/apps/tftp/tftp.c b/lib/lwip/lwip/src/apps/tftp/tftp.c index ddfdbfc0c1b..74fc1fbe586 100644 --- a/lib/lwip/lwip/src/apps/tftp/tftp.c +++ b/lib/lwip/lwip/src/apps/tftp/tftp.c @@ -454,10 +454,12 @@ tftp_init_common(u8_t mode, const struct tftp_context *ctx) return ERR_MEM; } - ret = udp_bind(pcb, IP_ANY_TYPE, TFTP_PORT); - if (ret != ERR_OK) { - udp_remove(pcb); - return ret; + if (mode == LWIP_TFTP_MODE_SERVER) { + ret = udp_bind(pcb, IP_ANY_TYPE, TFTP_PORT); + if (ret != ERR_OK) { + udp_remove(pcb); + return ret; + } } tftp_state.handle = NULL; |