Skip to content

Commit b6014c5

Browse files
akihikodakidwmw2
authored andcommitted
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 <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: David Woodhouse <[email protected]>
1 parent 981780c commit b6014c5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

hw/i386/kvm/xen_xenstore.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,10 @@ static void xs_read(XenXenstoreState *s, unsigned int req_id,
532532
return;
533533
}
534534

535+
if (!len) {
536+
return;
537+
}
538+
535539
memcpy(&rsp_data[rsp->len], data->data, len);
536540
rsp->len += len;
537541
}

0 commit comments

Comments
 (0)