[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] tools/libxenhypfs: fix reading of gzipped string



commit 971275352691869b227f11b92d21303c567ddfb3
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Mon Jan 18 13:06:28 2021 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Mon Jan 18 13:52:40 2021 +0000

    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 <jgross@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 tools/libs/hypfs/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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);
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.