From: Grant Likely Date: Thu, 30 Aug 2007 00:26:24 +0000 (-0600) Subject: tftp: don't implicity trust the format of recevied packets X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=8f1bc28408ded213418d9bc0780c7d8fb8a03774;p=project%2Fbcm63xx%2Fu-boot.git tftp: don't implicity trust the format of recevied packets The TFTP OACK code trusts that the incoming packet is formated as ASCII text and can be processed by string functions. It also has a loop limit overflow bug where if the packet length is less than 8, it ends up looping over *all* of memory to find the 'blksize' string. This patch solves the problem by forcing the packet to be null terminated and using strstr() to search for the sub string. Signed-off-by: Grant Likely --- diff --git a/net/tftp.c b/net/tftp.c index fb2f50564e..27f5e88be8 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -238,9 +238,9 @@ TftpSend (void) static void TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) { + char * blksize; ushort proto; ushort *s; - int i; if (dest != TftpOurPort) { #ifdef CONFIG_MCAST_TFTP @@ -272,22 +272,22 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) case TFTP_OACK: #ifdef ET_DEBUG - printf("Got OACK: %s %s\n", pkt, pkt+strlen(pkt)+1); + printf("Got OACK:\n"); + print_buffer (0, pkt, 1, len, 16); #endif TftpState = STATE_OACK; TftpServerPort = src; + /* Check for 'blksize' option */ - for (i=0;i