diff options
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r-- | lib9p/srv.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c index 085cc8b..f4b904e 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -1301,10 +1301,17 @@ static void handle_Tread(struct srv_req *ctx, if (iov.is_err) { err = iov.err; } else { - resp.count = iov.iovec.iov_len; - resp.data = iov.iovec.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); } break; case SRV_FILETYPE_AUTH: |