diff options
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2012-01-27 17:58:20 +0000 |
---|---|---|
committer | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2012-01-27 17:58:20 +0000 |
commit | 0d655213015bd839f63f0d527e39318cf8ee713f (patch) | |
tree | eea1f6e41f1e60c03452ede078512f4ab421ce25 /tools/libxl/libxl_qmp.c | |
parent | ade17521489197781e655b78f2e0d30eff5b4ab6 (diff) | |
download | xen-0d655213015bd839f63f0d527e39318cf8ee713f.tar.gz xen-0d655213015bd839f63f0d527e39318cf8ee713f.tar.bz2 xen-0d655213015bd839f63f0d527e39318cf8ee713f.zip |
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 <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_qmp.c')
-rw-r--r-- | 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 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"); |