svn commit: r305116 - head/lib/libstand
Toomas Soome
tsoome at FreeBSD.org
Wed Aug 31 09:23:11 UTC 2016
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]);
More information about the svn-src-head
mailing list