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

[Xen-devel] [PATCH] libxl_qmp: fix qmp_next



qmp_next doesn't handle multiple lines read together in a single buffer
correctly at the moment.
This patch fixes it.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/libxl/libxl_qmp.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index f77365b..41a12ad 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -412,17 +412,18 @@ do_select_again:
             char *end = NULL;
             if (incomplete) {
                 size_t current_pos = s - incomplete;
-                incomplete_size += rd;
                 incomplete = libxl__realloc(gc, incomplete,
-                                            incomplete_size + 1);
-                incomplete = strncat(incomplete, qmp->buffer, rd);
+                                            incomplete_size + rd);
+                strncat(incomplete + incomplete_size, qmp->buffer, rd);
                 s = incomplete + current_pos;
+                incomplete_size += rd;
                 s_end = incomplete + incomplete_size;
             } else {
                 incomplete = libxl__strndup(gc, qmp->buffer, rd);
                 incomplete_size = rd;
                 s = incomplete;
                 s_end = s + rd;
+                rd = 0;
             }
 
             end = strstr(s, "\r\n");
-- 
1.7.2.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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