[PATCH 2/3] tftp_recv(): according to RFC1350 minimal tftp packet length is 4 bytes

Antony Pavlov antonynpavlov at gmail.com
Sun Jun 28 09:19:39 PDT 2015


Signed-off-by: Antony Pavlov <antonynpavlov at 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




More information about the barebox mailing list