0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-01 19:22:53 +01:00

ircd::fs: Handle zero length buffers in the iov.

This commit is contained in:
Jason Volk 2019-03-16 13:49:04 -07:00
parent 7fc68e1933
commit e752070d06

View file

@ -1412,12 +1412,14 @@ ircd::fs::make_iov(const iovec_view &iov,
size_t i(0), off(0); size_t i(0), off(0);
for(; i < max; off += size(bufs[i++])) for(; i < max; off += size(bufs[i++]))
if(size(bufs[i]) > offset - off) if(size(bufs[i]) >= offset - off)
{ {
assert(offset >= off);
off = offset - off; off = offset - off;
break; break;
} }
assert(i <= max);
if(i < max) if(i < max)
{ {
assert(off <= size(bufs[i])); assert(off <= size(bufs[i]));
@ -1433,6 +1435,7 @@ ircd::fs::make_iov(const iovec_view &iov,
}; };
} }
assert(i <= max);
const const_iovec_view ret{iov.data(), i}; const const_iovec_view ret{iov.data(), i};
assert(bytes(ret) <= buffer::buffers::size(bufs)); assert(bytes(ret) <= buffer::buffers::size(bufs));
return ret; return ret;
@ -1451,12 +1454,14 @@ ircd::fs::make_iov(const iovec_view &iov,
size_t i(0), off(0); size_t i(0), off(0);
for(; i < max; off += size(bufs[i++])) for(; i < max; off += size(bufs[i++]))
if(size(bufs[i]) > offset - off) if(size(bufs[i]) >= offset - off)
{ {
assert(offset >= off);
off = offset - off; off = offset - off;
break; break;
} }
assert(i <= max);
if(i < max) if(i < max)
{ {
assert(off <= size(bufs[i])); assert(off <= size(bufs[i]));
@ -1472,6 +1477,7 @@ ircd::fs::make_iov(const iovec_view &iov,
}; };
} }
assert(i <= max);
const const_iovec_view ret{iov.data(), i}; const const_iovec_view ret{iov.data(), i};
assert(bytes(ret) <= buffer::buffers::size(bufs)); assert(bytes(ret) <= buffer::buffers::size(bufs));
return ret; return ret;