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
@ -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…
x
Reference in New Issue
Block a user