From 0e12f6eb1b3e6c6e447586c0b72edf1663c0ae96 Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Tue, 30 Aug 2022 09:37:59 +0200 Subject: tftp: do not set 'tsize' in WRQ requests The filesize is not known for push requests and barebox always sent '0'. Server might reject data because it will always exceed this length. Send this option only for RRQ requests. Signed-off-by: Enrico Scholz Link: https://lore.barebox.org/20220830073816.2694734-5-enrico.scholz@sigma-chemnitz.de Signed-off-by: Sascha Hauer --- fs/tftp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'fs') diff --git a/fs/tftp.c b/fs/tftp.c index 913ca1df6e..361661d218 100644 --- a/fs/tftp.c +++ b/fs/tftp.c @@ -132,18 +132,23 @@ static int tftp_send(struct file_priv *priv) "octet%c" "timeout%c" "%d%c" - "tsize%c" - "%lld%c" "blksize%c" "1432", priv->filename + 1, 0, 0, 0, TIMEOUT, 0, - 0, - priv->filesize, 0, 0); pkt++; + + if (!priv->push) + /* we do not know the filesize in WRQ requests and + 'priv->filesize' will always be zero */ + pkt += sprintf((unsigned char *)pkt, + "tsize%c%lld%c", + '\0', priv->filesize, + '\0'); + len = pkt - xp; break; -- cgit v1.2.1