Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Aug 2016 09:23:10 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r305116 - head/lib/libstand
Message-ID:  <201608310923.u7V9NAOu041307@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tsoome
Date: Wed Aug 31 09:23:09 2016
New Revision: 305116
URL: https://svnweb.freebsd.org/changeset/base/305116

Log:
  recvtftp() is broken for large files, report file size
  
  The tftp download for large files will cause internal block id
  to wrap to 0 as the data type is unsigned short.
  
  Also provide file size information for stat.
  
  PR:		200500
  Reported by:	tsoome
  Reviewed by:	allanjude
  Approved by:	allanjude (mentor)
  Differential Revision:	https://reviews.freebsd.org/D7660

Modified:
  head/lib/libstand/tftp.c

Modified: head/lib/libstand/tftp.c
==============================================================================
--- head/lib/libstand/tftp.c	Wed Aug 31 07:42:46 2016	(r305115)
+++ head/lib/libstand/tftp.c	Wed Aug 31 09:23:09 2016	(r305116)
@@ -200,7 +200,7 @@ recvtftp(struct tftp_handle *h, void *pk
 	case DATA: {
 		int got;
 
-		if (htons(t->th_block) != d->xid) {
+		if (htons(t->th_block) != (u_short) d->xid) {
 			/*
 			 * Expected block?
 			 */
@@ -560,7 +560,7 @@ tftp_stat(struct open_file *f, struct st
 	sb->st_nlink = 1;
 	sb->st_uid = 0;
 	sb->st_gid = 0;
-	sb->st_size = -1;
+	sb->st_size = (off_t) tftpfile->tftp_tsize;
 	return (0);
 }
 
@@ -731,6 +731,8 @@ tftp_parse_oack(struct tftp_handle *h, c
 	    } else if (strcasecmp(tftp_options[i], "tsize") == 0) {
 		if (i + 1 < option_idx)
 			tsize = strtol(tftp_options[i + 1], (char **)NULL, 10);
+		if (tsize != 0)
+			h->tftp_tsize = tsize;
 	    } else {
 		/* Do not allow any options we did not expect to be ACKed. */
 		printf("unexpected tftp option '%s'\n", tftp_options[i]);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608310923.u7V9NAOu041307>