xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/libxenhypfs: fix reading of gzipped string
@ 2021-01-18 12:06 Juergen Gross
  2021-01-18 13:27 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Juergen Gross @ 2021-01-18 12:06 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tools/libxenhypfs: fix reading of gzipped string
  2021-01-18 12:06 [PATCH] tools/libxenhypfs: fix reading of gzipped string Juergen Gross
@ 2021-01-18 13:27 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2021-01-18 13:27 UTC (permalink / raw)
  To: Juergen Gross, xen-devel; +Cc: Ian Jackson, Wei Liu

On 18/01/2021 12:06, Juergen Gross wrote:
> 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 | 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);



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-18 13:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 12:06 [PATCH] tools/libxenhypfs: fix reading of gzipped string Juergen Gross
2021-01-18 13:27 ` Andrew Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).