Prevent block counter rollover
authorJoseph C. Lehner <joseph.c.lehner@gmail.com>
Mon, 29 Apr 2019 08:51:38 +0000 (10:51 +0200)
committerJoseph C. Lehner <joseph.c.lehner@gmail.com>
Mon, 29 Apr 2019 08:51:38 +0000 (10:51 +0200)
tftp.c

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