mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 2/3] tftp_recv(): according to RFC1350 minimal tftp packet length is 4 bytes
Date: Sun, 28 Jun 2015 19:19:39 +0300	[thread overview]
Message-ID: <1435508380-21284-3-git-send-email-antonynpavlov@gmail.com> (raw)
In-Reply-To: <1435508380-21284-1-git-send-email-antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 fs/tftp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/tftp.c b/fs/tftp.c
index d970c60..e36c1c8 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -259,7 +259,8 @@ static void tftp_recv(struct file_priv *priv,
 	uint16_t proto;
 	uint16_t *s;
 
-	if (len < 2)
+	/* according to RFC1350 minimal tftp packet length is 4 bytes */
+	if (len < 4)
 		return;
 
 	len -= 2;
@@ -315,8 +316,6 @@ static void tftp_recv(struct file_priv *priv,
 
 		break;
 	case TFTP_DATA:
-		if (len < 2)
-			return;
 		len -= 2;
 		priv->block = ntohs(*(uint16_t *)pkt);
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-06-28 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-28 16:19 [PATCH 0/3] tftp: prepare for picotcp Antony Pavlov
2015-06-28 16:19 ` [PATCH 1/3] fs/tftp: handle incoming packets in the separate tftp_recv() function Antony Pavlov
2015-06-28 16:19 ` Antony Pavlov [this message]
2015-06-28 16:19 ` [PATCH 3/3] tftp_recv(): handle opcode field in a more natural way Antony Pavlov
2015-06-29  5:25 ` [PATCH 0/3] tftp: prepare for picotcp Sascha Hauer

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=1435508380-21284-3-git-send-email-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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