mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
hw/xen: Check if len is 0 before memcpy()
data->data can be NULL when len is 0. Strictly speaking, the behavior of memcpy() in such a scenario is undefined so UBSan complaints. Satisfy UBSan by checking if len is 0 before memcpy(). Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
This commit is contained in:
parent
981780cdda
commit
b6014c5089
1 changed files with 4 additions and 0 deletions
|
@ -532,6 +532,10 @@ static void xs_read(XenXenstoreState *s, unsigned int req_id,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!len) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(&rsp_data[rsp->len], data->data, len);
|
memcpy(&rsp_data[rsp->len], data->data, len);
|
||||||
rsp->len += len;
|
rsp->len += len;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue