libxl: Do not generate short block in libxl__datacopier_prefixdata
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 3 Sep 2013 12:41:46 +0000 (13:41 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 12 Nov 2013 17:24:51 +0000 (17:24 +0000)
libxl__datacopier_prefixdata would prepend a deliberately short block
(not just a half-full one, but one with a short buffer) to the
dc->bufs queue.  However, this is wrong because datacopier_readable
will find it and try to continue to fill it up.

Instead, allocate a full-sized buffer.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Tested-by: Chunyan Liu <cyliu@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl_aoutils.c

index 983a60afc711947aa0cb19035761f88b7331981b..b4eb6e52845db59db9ad0410336d919ca54d23bb 100644 (file)
@@ -89,7 +89,7 @@ void libxl__datacopier_prefixdata(libxl__egc *egc, libxl__datacopier_state *dc,
 
     assert(len < dc->maxsz - dc->used);
 
-    buf = libxl__zalloc(NOGC, sizeof(*buf) - sizeof(buf->buf) + len);
+    buf = libxl__zalloc(NOGC, sizeof(*buf));
     buf->used = len;
     memcpy(buf->buf, data, len);