From 911d824aa2f13cfe8297dfdde44fe069203dcba8 Mon Sep 17 00:00:00 2001 From: kevans Date: Sat, 10 Feb 2018 01:52:58 +0000 Subject: [PATCH] MFC libstand catch-up: r305116,306534,306538,306552,306638 r305116: recvtftp() is broken for large files, report file size r306534: cd9660_open should check for padding r306538: cstyle fix of cd9660_open in libstand r306552: Fix remaining cstyle issues in libstand/cd9660.c r306638: Fix remaining bugs in libstand/cd9660.c reported by Bruce Evans. PR: 200500 --- lib/libstand/cd9660.c | 6 ++++++ lib/libstand/tftp.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/libstand/cd9660.c b/lib/libstand/cd9660.c index d020e76a1b6..c5618838e4a 100644 --- a/lib/libstand/cd9660.c +++ b/lib/libstand/cd9660.c @@ -353,6 +353,12 @@ cd9660_open(const char *path, struct open_file *f) dp = (struct iso_directory_record *) ((char *) dp + isonum_711(dp->length)); + /* If the new block has zero length, it is padding. */ + if (isonum_711(dp->length) == 0) { + /* Skip to next block, if any. */ + off = boff * ISO_DEFAULT_BLOCK_SIZE; + continue; + } off += isonum_711(dp->length); } if (off >= dsize) { diff --git a/lib/libstand/tftp.c b/lib/libstand/tftp.c index 621cfd8a15d..b3d2da7b0ed 100644 --- a/lib/libstand/tftp.c +++ b/lib/libstand/tftp.c @@ -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? */ @@ -563,7 +563,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); } @@ -734,6 +734,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]); -- 2.45.0