From 0373577005398f5212351ef708c2a95368a74bad Mon Sep 17 00:00:00 2001 From: "Joseph C. Lehner" Date: Thu, 5 Sep 2019 15:38:29 +0200 Subject: [PATCH] Warn about TFTP block rollover --- tftp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tftp.c b/tftp.c index 06258dc..27ca320 100644 --- a/tftp.c +++ b/tftp.c @@ -314,6 +314,7 @@ int tftp_put(struct nmrpd_args *args) char rx[2048], tx[2048]; const char *file_remote = args->file_remote; char *val, *end; + bool rollover; sock = -1; ret = -1; @@ -373,6 +374,7 @@ int tftp_put(struct nmrpd_args *args) last_len = -1; len = 0; errors = 0; + rollover = false; /* Not really, but this way the loop sends our WRQ before receiving */ timeouts = 1; @@ -394,6 +396,10 @@ int tftp_put(struct nmrpd_args *args) ret = -1; goto cleanup; } + + if (verbosity) { + printf("Remote accepted blksize option: %d b\n", blksize); + } } } } @@ -401,8 +407,10 @@ int tftp_put(struct nmrpd_args *args) if (timeouts || ackblock == block) { if (!timeouts) { if (++block == 0) { - // rollover; skip to block 1 - block = 1; + if (!rollover) { + printf("Warning: TFTP block rollover. Upload might fail!\n"); + rollover = true; + } } pkt_mknum(tx, DATA); -- 2.25.1