net: tftp: Fix tftp_prev_block counter update
authorLey Foon Tan <ley.foon.tan@intel.com>
Tue, 25 Aug 2020 02:26:35 +0000 (10:26 +0800)
committerTom Rini <trini@konsulko.com>
Wed, 30 Sep 2020 20:48:18 +0000 (16:48 -0400)
Fixes missing update to tftp_prev_block counter before increase
tftp_cur_block counter when do the tftpput operation.

tftp_prev_block counter is used in update_block_number() function to
check whether block number (sequence number) is rollover. This bug
cause the tftpput command fail to upload a large file when block
number is greater than 16-bit (0xFFFF).

Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Reviewed-By: Ramon Fried <rfried.dev@gmail.com>
net/tftp.c

index 84e970b..380094d 100644 (file)
@@ -502,6 +502,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
                                int block = ntohs(*s);
                                int ack_ok = (tftp_cur_block == block);
 
+                               tftp_prev_block = tftp_cur_block;
                                tftp_cur_block = (unsigned short)(block + 1);
                                update_block_number();
                                if (ack_ok)