From: Juergen Gross Date: Mon, 18 Jan 2021 12:06:28 +0000 (+0100) Subject: tools/libxenhypfs: fix reading of gzipped string X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~1130 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=971275352691869b227f11b92d21303c567ddfb3;p=xen.git tools/libxenhypfs: fix reading of gzipped string Reading a gzipped string value from hypfs doesn't add a 0 byte at the end. Fix that. Fixes: 86234eafb95295 ("libs: add libxenhypfs") Signed-off-by: Juergen Gross Acked-by: Andrew Cooper --- diff --git a/tools/libs/hypfs/core.c b/tools/libs/hypfs/core.c index f94c5ea1e2..52b30db8d7 100644 --- a/tools/libs/hypfs/core.c +++ b/tools/libs/hypfs/core.c @@ -146,12 +146,13 @@ static void *xenhypfs_inflate(void *in_data, size_t *sz) break; out_sz = z.next_out - workbuf; - content = realloc(content, *sz + out_sz); + content = realloc(content, *sz + out_sz + 1); if (!content) { ret = Z_MEM_ERROR; break; } memcpy(content + *sz, workbuf, out_sz); + *(char *)(content + *sz + out_sz) = 0; } inflateEnd(&z);