[PATCH 2/2] net: tftp: Fix TFTP Transfer Size data type
Marek Vasut
marek.vasut+renesas at mailbox.org
Thu Jan 29 23:30:19 CET 2026
From: Yuya Hamamachi <yuya.hamamachi.sx at renesas.com>
The TFTP transfer size is unsigned integer, update the data type
and print formating string accordingly to prevent an overflow in
case the file size is longer than 2 GiB.
TFTP transfer of a 3 GiB file, before (wrong) and after (right):
Loading: ################################################# 16 EiB
Loading: ################################################## 3 GiB
Signed-off-by: Yuya Hamamachi <yuya.hamamachi.sx at renesas.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: "Alvin Šipraga" <alvin at pqrs.dk>
Cc: Alexander Sverdlin <alexander.sverdlin at siemens.com>
Cc: Andre Przywara <andre.przywara at arm.com>
Cc: Andrew Goodbody <andrew.goodbody at linaro.org>
Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
Cc: Jerome Forissier <jerome at forissier.org>
Cc: Joe Hershberger <joe.hershberger at ni.com>
Cc: Leonard Anderweit <l.anderweit at phytec.de>
Cc: Marek Vasut <marek.vasut+renesas at mailbox.org>
Cc: Mattijs Korpershoek <mkorpershoek at kernel.org>
Cc: Quentin Schulz <quentin.schulz at cherry.de>
Cc: Ramon Fried <rfried.dev at gmail.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Tom Rini <trini at konsulko.com>
Cc: Yuya Hamamachi <yuya.hamamachi.sx at renesas.com>
Cc: u-boot at lists.denx.de
---
net/tftp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/tftp.c b/net/tftp.c
index 78ec44159c1..5f2e0a2bc06 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -94,7 +94,7 @@ static int tftp_state;
static ulong tftp_load_addr;
#ifdef CONFIG_TFTP_TSIZE
/* The file size reported by the server */
-static int tftp_tsize;
+static unsigned int tftp_tsize;
/* The number of hashes we printed */
static short tftp_tsize_num_hash;
#endif
@@ -573,7 +573,7 @@ static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
if (strcasecmp((char *)pkt + i, "tsize") == 0) {
tftp_tsize = dectoul((char *)pkt + i + 6,
NULL);
- debug("size = %s, %d\n",
+ debug("size = %s, %u\n",
(char *)pkt + i + 6, tftp_tsize);
}
#endif
--
2.51.0
More information about the U-Boot
mailing list