diff options
author | Ley Foon Tan <ley.foon.tan@intel.com> | 2020-08-25 10:26:37 +0800 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-09-30 16:48:18 -0400 |
commit | f6a158b996b3abee4e6315b29a488398cb3946df (patch) | |
tree | 53db6ad1efad50666b6e94ce4b4ec9516be0e3e0 /net | |
parent | ae0bdf09ca9737d5db9453966cf4705bdd420d31 (diff) | |
download | u-boot-f6a158b996b3abee4e6315b29a488398cb3946df.tar.gz u-boot-f6a158b996b3abee4e6315b29a488398cb3946df.tar.bz2 u-boot-f6a158b996b3abee4e6315b29a488398cb3946df.zip |
net: tftp: Fix load_block offset calculation
When load the last block, the "len" might not be a block size. This cause
loading the incorrect last block data.
The fix change "len" to tftp_block_size and minus one tftp_block_size
for offset calculation.
Use same offset calculation formula as in store_block().
Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Reviewed-By: Ramon Fried <rfried.dev@gmail.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/tftp.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/tftp.c b/net/tftp.c index 1c003871c1..6fdb1a821a 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -234,7 +234,8 @@ static void new_transfer(void) static int load_block(unsigned block, uchar *dst, unsigned len) { /* We may want to get the final block from the previous set */ - ulong offset = ((int)block - 1) * len + tftp_block_wrap_offset; + ulong offset = block * tftp_block_size + tftp_block_wrap_offset - + tftp_block_size; ulong tosend = len; tosend = min(net_boot_file_size - offset, tosend); |