commit d8dd8bd77f67af6bb2047bda0fa010ff80d36be5 from: Omar Polo date: Sun Jan 02 10:42:18 2022 UTC tread: read at most the requested size spotted by cage, thanks! commit - 98576296154a0e6fe5c6fc4b3b517cfb9c3e4402 commit + d8dd8bd77f67af6bb2047bda0fa010ff80d36be5 blob - 677d0175769dee1f73404b966c7291e325e408aa blob + 8802f85f95e5518dd7736cf73df9e190da4c0e8b --- client.c +++ client.c @@ -1371,6 +1371,7 @@ tread(struct np_msg_header *hdr, const uint8_t *data, { struct fid *f; ssize_t r; + size_t howmuch; uint64_t off; uint32_t fid, count; char buf[2048]; @@ -1397,7 +1398,8 @@ tread(struct np_msg_header *hdr, const uint8_t *data, if (f->d == NULL) { /* read a file */ - r = pread(f->fd, buf, sizeof(buf), (off_t)off); + howmuch = MIN(sizeof(buf), count); + r = pread(f->fd, buf, howmuch, (off_t)off); if (r == -1) np_errno(hdr->tag); else