summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmos Kong <akong@redhat.com>2013-11-21 16:42:51 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2013-11-21 17:39:17 +0100
commitfbdcec5c487685b46e78f1e40a236ebf83f862fa (patch)
tree007352da9a26c69eb5abbbcbf1db8ce1a7573a56
parent60aad298cb6de52f2716b2e82e1353ea9de95fd6 (diff)
downloadqemu-fbdcec5c487685b46e78f1e40a236ebf83f862fa.zip
rng-egd: offset the point when repeatedly read from the buffer
The buffer content might be read out more than once, currently we just repeatedly read the first data block, buffer offset is missing. Cc: qemu-stable@nongnu.org Signed-off-by: Amos Kong <akong@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--backends/rng-egd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index 6f56f9e4e4..25bb3b453b 100644
--- a/backends/rng-egd.c
+++ b/backends/rng-egd.c
@@ -91,12 +91,14 @@ static int rng_egd_chr_can_read(void *opaque)
static void rng_egd_chr_read(void *opaque, const uint8_t *buf, int size)
{
RngEgd *s = RNG_EGD(opaque);
+ size_t buf_offset = 0;
while (size > 0 && s->requests) {
RngRequest *req = s->requests->data;
int len = MIN(size, req->size - req->offset);
- memcpy(req->data + req->offset, buf, len);
+ memcpy(req->data + req->offset, buf + buf_offset, len);
+ buf_offset += len;
req->offset += len;
size -= len;