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
This commit is contained in:
parent
bf77189f92
commit
9edcae95e4
@ -200,7 +200,7 @@ recvtftp(struct tftp_handle *h, void *pkt, ssize_t len, time_t tleft,
|
||||
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 stat *sb)
|
||||
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, char *buf, size_t len)
|
||||
} 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]);
|
||||
|
Loading…
Reference in New Issue
Block a user