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

[xen staging] tools/xenstored: Correctly read the requests header from the stream



commit 8a9b94982b0e0928ad874907f5a5b005944ab7cf
Author:     Julien Grall <jgrall@xxxxxxxxxx>
AuthorDate: Fri Jun 25 07:45:22 2021 +0100
Commit:     Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Fri Jun 25 10:40:06 2021 +0100

    tools/xenstored: Correctly read the requests header from the stream
    
    Commit c0fe360f42 ("tools/xenstored: Extend restore code to handle
    multiple input buffer") extend the read_buffered_state() to support
    multiple input buffers. Unfortunately, the commit didn't go far
    enough and still used sc->data (start of the buffers) for retrieving
    the header. This would lead to read the wrong headers for second and
    follow-up commands.
    
    Use data in place for sc->data for the source of the memcpy()s.
    
    Fixes: c0fe360f42 ("tools/xenstored: Extend restore code to handle multiple 
input buffer")
    Reported-by: Raphael Ning <raphning@xxxxxxxxxx>
    Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
    Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
---
 tools/xenstore/xenstored_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index cf7297a96c..16c856730c 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -2717,11 +2717,11 @@ void read_state_buffered_data(const void *ctx, struct 
connection *conn,
                len = sc->data_in_len - (data - sc->data);
                if (len < sizeof(bdata->hdr)) {
                        bdata->inhdr = true;
-                       memcpy(&bdata->hdr, sc->data, len);
+                       memcpy(&bdata->hdr, data, len);
                        bdata->used = len;
                } else {
                        bdata->inhdr = false;
-                       memcpy(&bdata->hdr, sc->data, sizeof(bdata->hdr));
+                       memcpy(&bdata->hdr, data, sizeof(bdata->hdr));
                        if (bdata->hdr.msg.len <= DEFAULT_BUFFER_SIZE)
                                bdata->buffer = bdata->default_buffer;
                        else
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.