From: Stefano Stabellini Subject: [PATCH] libxl_qmp: fix qmp_next Date: Wed, 25 Jan 2012 16:07:04 +0000 Message-ID: <1327507624-1914-1-git-send-email-stefano.stabellini@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: anthony.perard@citrix.com, Stefano Stabellini List-Id: xen-devel@lists.xenproject.org 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 --- 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