summaryrefslogtreecommitdiff
path: root/lib9p/srv.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r--lib9p/srv.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 50d0b78..2c26ffe 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -980,13 +980,20 @@ static void handle_Tread(struct _lib9p_srv_req *ctx,
fidinfo->dir.idx = idx+num;
fidinfo->dir.off = req->offset + len;
} else {
- struct iovec iov;
- LO_CALL(fidinfo->file.io, pread, &ctx->ctx, req->count, req->offset, &iov);
+ LO_CALL(fidinfo->file.io, pread, &ctx->ctx, req->count, req->offset,
+ &resp->iov, &resp->iovcnt);
if (!lib9p_ctx_has_error(&ctx->ctx.basectx)) {
- resp->count = iov.iov_len;
- resp->data = iov.iov_base;
- if (resp->count > req->count)
- resp->count = req->count;
+ resp->count = 0;
+ assert(resp->iovcnt >= 0);
+ if (resp->iovcnt) {
+ assert(resp->iov);
+ for (int i = 0; i < resp->iovcnt; i++) {
+ assert(resp->iov[i].iov_len == 0 || resp->iov[i].iov_base);
+ bool overflowed = __builtin_add_overflow(resp->count, resp->iov[i].iov_len, &resp->count);
+ assert(!overflowed);
+ }
+ }
+ assert(resp->count <= req->count);
}
}
}