public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] TFTP - check for len == 0 before storing
@ 2011-04-20  8:21 David Andrey
  2011-04-20 13:46 ` Detlev Zundel
  0 siblings, 1 reply; 2+ messages in thread
From: David Andrey @ 2011-04-20  8:21 UTC (permalink / raw)
  To: u-boot

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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] TFTP - check for len == 0 before storing
  2011-04-20  8:21 [U-Boot] TFTP - check for len == 0 before storing David Andrey
@ 2011-04-20 13:46 ` Detlev Zundel
  0 siblings, 0 replies; 2+ messages in thread
From: Detlev Zundel @ 2011-04-20 13:46 UTC (permalink / raw)
  To: u-boot

Hi David,

> 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.

Please look at our patch guidelines[1] on how to submit patches.
Especially a signed-off-by is missing on this patch.

Moreover, please put the explanation into the commit log so that one can
learn the rationale for the change when studying the source with git.

Thanks
  Detlev

[1] http://www.denx.de/wiki/U-Boot/Patches

-- 
LISP has  jokingly been  described as  "the most  intelligent way to  misuse a
computer".  I think that  description a great  compliment because it transmits
the full  flavour of  liberation:  it has assisted a number of our most gifted
fellow humans in thinking previously impossible thoughts. - Edsger W. Dijkstra
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-20 13:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-20  8:21 [U-Boot] TFTP - check for len == 0 before storing David Andrey
2011-04-20 13:46 ` Detlev Zundel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox