From 9a9abfc07cccdfbcdb3d1479938de8ed7c504359 Mon Sep 17 00:00:00 2001 From: "Joseph C. Lehner" Date: Mon, 2 Mar 2020 08:34:44 +0100 Subject: [PATCH] Don't use -t timeout for TFTP transfers --- nmrpd.h | 4 ++++ tftp.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/nmrpd.h b/nmrpd.h index 086d2af..d65c811 100644 --- a/nmrpd.h +++ b/nmrpd.h @@ -62,6 +62,10 @@ #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + #ifndef PACKED #define PACKED __attribute__((packed)) #endif diff --git a/tftp.c b/tftp.c index b6f5ce7..9fd361a 100644 --- a/tftp.c +++ b/tftp.c @@ -315,6 +315,7 @@ int tftp_put(struct nmrpd_args *args) const char *file_remote = args->file_remote; char *val, *end; bool rollover; + unsigned rx_timeout = MAX(args->rx_timeout / 200, 1); sock = -1; ret = -1; @@ -367,6 +368,7 @@ int tftp_put(struct nmrpd_args *args) xperror("inet_addr"); goto cleanup; } + addr.sin_port = htons(args->port); blksize = 512; @@ -447,7 +449,7 @@ int tftp_put(struct nmrpd_args *args) } } - ret = tftp_recvfrom(sock, rx, &port, args->rx_timeout, blksize + 4); + ret = tftp_recvfrom(sock, rx, &port, rx_timeout, blksize + 4); if (ret < 0) { goto cleanup; } else if (!ret) { -- 2.25.1