From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>, Ian Jackson <iwj@xenproject.org>,
Wei Liu <wl@xen.org>
Subject: [PATCH] tools/libxenhypfs: fix reading of gzipped string
Date: Mon, 18 Jan 2021 13:06:28 +0100 [thread overview]
Message-ID: <20210118120628.11722-1-jgross@suse.com> (raw)
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>
---
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);
--
2.26.2
next reply other threads:[~2021-01-18 12:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 12:06 Juergen Gross [this message]
2021-01-18 13:27 ` [PATCH] tools/libxenhypfs: fix reading of gzipped string Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210118120628.11722-1-jgross@suse.com \
--to=jgross@suse.com \
--cc=iwj@xenproject.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.