qemu-stable
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-stable] [PULL 08/11] rng-egd: offset the point when repeatedly rea


From: Paolo Bonzini
Subject: [Qemu-stable] [PULL 08/11] rng-egd: offset the point when repeatedly read from the buffer
Date: Thu, 21 Nov 2013 17:49:35 +0100

From: Amos Kong <address@hidden>

The buffer content might be read out more than once, currently
we just repeatedly read the first data block, buffer offset is
missing.

Cc: address@hidden
Signed-off-by: Amos Kong <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
 backends/rng-egd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/backends/rng-egd.c b/backends/rng-egd.c
index 6f56f9e..25bb3b4 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;
 
-- 
1.8.3.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]