[PATCH 01/13] net: tftp: Increase TFTP pkt string length to include null character
Chintan Vankar
c-vankar at ti.com
Tue Jan 7 10:38:28 CET 2025
'sprintf()' function defined in 'tiny-printf.c' is returning length of the
string excluding null character. Fix this by increasing TFTP pkt length by
1 to avoid TFTP error of request being not-null terminated while
requesting length of packet.
Signed-off-by: Chintan Vankar <c-vankar at ti.com>
---
net/tftp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/tftp.c b/net/tftp.c
index 704b20b4ff8..db1d4aacb0e 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -347,11 +347,11 @@ static void tftp_send(void)
pkt += strlen((char *)pkt) + 1;
#ifdef CONFIG_TFTP_TSIZE
pkt += sprintf((char *)pkt, "tsize%c%u%c",
- 0, net_boot_file_size, 0);
+ 0, net_boot_file_size, 0) + 1;
#endif
/* try for more effic. blk size */
pkt += sprintf((char *)pkt, "blksize%c%d%c",
- 0, tftp_block_size_option, 0);
+ 0, tftp_block_size_option, 0) + 1;
/* try for more effic. window size.
* Implemented only for tftp get.
@@ -359,7 +359,7 @@ static void tftp_send(void)
*/
if (tftp_state == STATE_SEND_RRQ && tftp_window_size_option > 1)
pkt += sprintf((char *)pkt, "windowsize%c%d%c",
- 0, tftp_window_size_option, 0);
+ 0, tftp_window_size_option, 0) + 1;
len = pkt - xp;
break;
--
2.34.1
More information about the U-Boot
mailing list