From owner-svn-src-head@freebsd.org Wed Aug 31 09:23:11 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2C2BCBC715A; Wed, 31 Aug 2016 09:23:11 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F05061D9; Wed, 31 Aug 2016 09:23:10 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7V9NAJh041308; Wed, 31 Aug 2016 09:23:10 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7V9NAOu041307; Wed, 31 Aug 2016 09:23:10 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201608310923.u7V9NAOu041307@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Wed, 31 Aug 2016 09:23:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305116 - head/lib/libstand X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2016 09:23:11 -0000 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]);