From: David Andrey <David.Andrey@netmodule.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] TFTP - check for len == 0 before storing
Date: Wed, 20 Apr 2011 10:21:01 +0200 [thread overview]
Message-ID: <1QCSeq-0004h5-4Z@wolf.netmodule.com> (raw)
Hello,
I had a problem with an old TFTP Server which is sending a second "last"
data block with "len == 0" at end. It's clearly not RFC conform, but I
still made a additional check in u-boot/tftp to avoid a wrong "filesize"
value. This wrong filesize value caused some trouble by NAND operations.
Regards
David
Date: Wed, 20 Apr 2011 10:12:10 +0200
Subject: [PATCH] Check for for data block len == 0
---
net/tftp.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/tftp.c b/net/tftp.c
index ed559b7..40d81b5 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -135,8 +135,14 @@ mcast_cleanup(void)
static __inline__ void
store_block (unsigned block, uchar * src, unsigned len)
{
- ulong offset = block * TftpBlkSize + TftpBlockWrapOffset;
- ulong newsize = offset + len;
+ ulong offset = 0;
+ ulong newsize = 0;
+
+ if (len == 0)
+ return;
+
+ offset = block * TftpBlkSize + TftpBlockWrapOffset;
+ newsize = offset + len;
#ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
int i, rc = 0;
next reply other threads:[~2011-04-20 8:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-20 8:21 David Andrey [this message]
2011-04-20 13:46 ` [U-Boot] TFTP - check for len == 0 before storing Detlev Zundel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1QCSeq-0004h5-4Z@wolf.netmodule.com \
--to=david.andrey@netmodule.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox