Browse Source

net: tftp: fix type of block arg to store_block

The block argument for store_block can be -1 when the tftp sequence
number rolls over (i.e TftpBlock == 0), so the first argument to
store_block has to be of type 'int' instead of 'unsigned'.

In our environment (gcc 4.4.5 mips toolchain), this causes incorrect
'offset' to be generated for storing the block, and the tftp block
with number 0 will be written elsewhere, resulting in a bad block in
the downloaded file and a memory corruption.

Signed-off-by: Jayachandran Chandrasekharan Nair <jayachandranc@netlogicmicro.com>
Jayachandran Chandrasekharan Nair 12 years ago
parent
commit
bc46dfac2f
1 changed files with 1 additions and 1 deletions
  1. 1 1
      net/tftp.c

+ 1 - 1
net/tftp.c

@@ -156,7 +156,7 @@ mcast_cleanup(void)
 #endif	/* CONFIG_MCAST_TFTP */
 #endif	/* CONFIG_MCAST_TFTP */
 
 
 static inline void
 static inline void
-store_block(unsigned block, uchar *src, unsigned len)
+store_block(int block, uchar *src, unsigned len)
 {
 {
 	ulong offset = block * TftpBlkSize + TftpBlockWrapOffset;
 	ulong offset = block * TftpBlkSize + TftpBlockWrapOffset;
 	ulong newsize = offset + len;
 	ulong newsize = offset + len;