client-node: improve memory checks

For MemPtr memory, we use the fd of the buffer metadata and chunk
info. Check that the memory is also in this block.
Check that all the memory of the buffer fits in the memory block.

See #1859
This commit is contained in:
Wim Taymans 2021-11-29 10:42:02 +01:00
parent d3cd36ab54
commit cff8ac0cab

View file

@ -810,9 +810,15 @@ do_port_use_buffers(struct impl *impl,
}
for (j = 0; j < buffers[i]->n_datas; j++) {
struct spa_data *d = buffers[i]->datas;
if (d->type == SPA_DATA_MemPtr)
endptr = SPA_PTROFF(d->data, d->maxsize, void);
if (d->type == SPA_DATA_MemPtr) {
if ((m = pw_mempool_find_ptr(impl->context->pool, d->data)) == NULL ||
m != mem)
return -EINVAL;
endptr = SPA_MAX(endptr, SPA_PTROFF(d->data, d->maxsize, void));
}
}
if (endptr > SPA_PTROFF(baseptr, mem->size, void))
return -EINVAL;
m = pw_mempool_import_block(this->client->pool, mem);
if (m == NULL)