]> xenbits.xensource.com Git - xen.git/commitdiff
tools/libxenhypfs: fix reading of gzipped string
authorJuergen Gross <jgross@suse.com>
Mon, 18 Jan 2021 12:06:28 +0000 (13:06 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 18 Jan 2021 13:52:40 +0000 (13:52 +0000)
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 <jgross@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libs/hypfs/core.c

index f94c5ea1e2f226d6f4ea12c3de34483ca22fb146..52b30db8d777c357fb85f3e936ce120d1431f421 100644 (file)
@@ -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);