fix rng-egd backend
cover fix rng-egd backend
The first is a trivial cleanup, the second patch fixes a memcpy bug in reading data from chardev to request data buffer.
Amos Kong (2):
rng-egd: remove redundant free
rng-egd: offset the point when repeatedly read from the buffer
backends/rng-egd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/2 rng-egd: remove redundant free
We didn't set default chr_name, the free is redundant.
--- backends/rng-egd.c | 1 - 1 file changed, 1 deletion(-)
backends/rng-egd.c +0 -1
@@ -167,7 +167,6 @@ static void rng_egd_set_chardev(Object *obj, const char *value, Error **errp)if (b->opened) {error_set (errp,QERR_PERMISSION_DENIED ); }else { -g_free (s->chr_name); s->chr_name =g_strdup (value); } }
Signature · 1 line
1.8.3.1
PATCH 2/2 rng-egd: offset the point when repeatedly read from the buffer
In reply to Amos KongThe buffer content might be read out more than once, currently we just repeatedly read the first data block, buffer offset is missing.
--- backends/rng-egd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
backends/rng-egd.c +3 -1
@@ -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;
Signature · 1 line
1.8.3.1
Il 21/11/2013 09:42, Amos Kong ha scritto:
Quoted 10 lines
The first is a trivial cleanup, the second patch fixes a memcpy bug in reading data from chardev to request data buffer.
Amos Kong (2):
rng-egd: remove redundant free
rng-egd: offset the point when repeatedly read from the bufferbackends/rng-egd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)