From: Stefano Stabellini Date: Fri, 27 Jan 2012 17:58:20 +0000 (+0000) Subject: libxl_qmp: fix qmp_next to cope with multiple lines read in a single buffer X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0d655213015bd839f63f0d527e39318cf8ee713f;p=xen.git libxl_qmp: fix qmp_next to cope with multiple lines read in a single buffer 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 Committed-by: Ian Jackson --- diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index f125b17fe3..a43838d85a 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -408,17 +408,18 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) 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");