Fix decompress out-of-bounds access (#463)

This commit is contained in:
mtheall 2020-06-01 03:03:12 -05:00 committed by GitHub
parent 8f06d03ca6
commit 80be51e93b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -229,9 +229,9 @@ iov_increment(iov_iter *it)
static inline void
iov_add(iov_iter *it, size_t size)
{
while(true)
while(size > 0)
{
assert(it->num <= it->cnt);
assert(it->num < it->cnt);
assert(it->iov[it->num].size > it->pos);
if(it->iov[it->num].size - it->pos > size)
@ -244,6 +244,7 @@ iov_add(iov_iter *it, size_t size)
// advance to next buffer
size -= it->iov[it->num].size - it->pos;
++it->num;
assert(size == 0 || it->num < it->cnt);
it->pos = 0;
}
}