From patchwork Wed Apr 20 08:21:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Andrey X-Patchwork-Id: 92113 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 630151008B4 for ; Wed, 20 Apr 2011 18:46:04 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9D9EB280C3; Wed, 20 Apr 2011 10:46:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j58tOAlxTf4n; Wed, 20 Apr 2011 10:46:02 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F194D2808F; Wed, 20 Apr 2011 10:45:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6A1FE2808F for ; Wed, 20 Apr 2011 10:45:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e4E8UA+vqzTC for ; Wed, 20 Apr 2011 10:45:56 +0200 (CEST) X-Greylist: delayed 1486 seconds by postgrey-1.27 at theia; Wed, 20 Apr 2011 10:45:54 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from wolf.netmodule.com (wolf.netmodule.com [194.29.26.243]) by theia.denx.de (Postfix) with ESMTPS id 0689E2808C for ; Wed, 20 Apr 2011 10:45:54 +0200 (CEST) Received: from localhost by wolf.netmodule.com with esmtp id 1QCSeq-0004h5-4Z; Wed, 20 Apr 2011 10:21:08 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Date: Wed, 20 Apr 2011 10:21:01 +0200 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: TFTP - check for len == 0 before storing Thread-Index: Acv/M+KEhnlelsc4Q0e+w+reBSTSJA== From: "David Andrey" To: Message-Id: <1QCSeq-0004h5-4Z@wolf.netmodule.com> Cc: biggerbadderben@gmail.com Subject: [U-Boot] TFTP - check for len == 0 before storing X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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;