Skip to contentSkip to conversation

libxl_qmp: fix qmp_next

PATCH In review Stefano Stabellini 2 participants 2 messages Jan 25, 2012 – Jan 27, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 tools/libxl/libxl_qmp.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
tools/libxl/libxl_qmp.c +4 -3
index f77365b..41a12ad 100644
@@ -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");
Signature · 1 line
1.7.2.5
#1 lore raw

Stefano Stabellini writes ("[Xen-devel] [PATCH] libxl_qmp: fix qmp_next"):

Quoted 3 lines

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