1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-07 21:17:55 +03:00

virBitmapNewCopy: Honor sizes of either bitmap when doing memcpy()

'virBitmapNewCopy()' allocates a new bitmap with the same number of bits
but uses the internal allocation length as argument for the memcpy()
operation to copy the bits. Due to bugs in other code these may not be
the same resulting into a buffer overflow if the source is
over-allocated. Use the buffer length of the target bitmap instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Peter Krempa 2024-10-17 09:47:07 +02:00
parent 99acc29557
commit cfe638ef80

View File

@ -582,7 +582,7 @@ virBitmapNewCopy(virBitmap *src)
{
virBitmap *dst = virBitmapNew(src->nbits);
memcpy(dst->map, src->map, src->map_len * sizeof(src->map[0]));
memcpy(dst->map, src->map, dst->map_len * sizeof(src->map[0]));
return dst;
}