Fix tftp block rollover
authorJoseph C. Lehner <joseph.c.lehner@gmail.com>
Fri, 26 Apr 2019 18:43:45 +0000 (20:43 +0200)
committerJoseph C. Lehner <joseph.c.lehner@gmail.com>
Fri, 26 Apr 2019 18:43:45 +0000 (20:43 +0200)
tftp.c

diff --git a/tftp.c b/tftp.c
index de8f765d010214cb3727d52892cabe2d2593e52d..06258dc4259e6967e6cf0fae71000b2a44e729cf 100644 (file)
--- a/tftp.c
+++ b/tftp.c
@@ -400,8 +400,10 @@ int tftp_put(struct nmrpd_args *args)
 
                if (timeouts || ackblock == block) {
                        if (!timeouts) {
-                               // TODO: set block to 1 if ++block == 0 ?
-                               ++block;
+                               if (++block == 0) {
+                                       // rollover; skip to block 1
+                                       block = 1;
+                               }
 
                                pkt_mknum(tx, DATA);
                                pkt_mknum(tx + 2, block);