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

Re: [PATCH] tools/libxenhypfs: fix reading of gzipped string


  • To: Juergen Gross <jgross@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 18 Jan 2021 13:27:16 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eKjB4QmQMokq86lYl1bkMdjaIUoDtsjnVmG7e0lvxKQ=; b=QovJTGkuIIHTOucSO8t7UNtHLqt8xcZ3Ci5GeD+jHHnn1WT0tdkYUokQPqEd4l7ISbPN+Ui3cTfTt38wNThdlICX/ipq/eiSMK8PFUxHkHizR3WaiarBZ1drN03Uxg6TLkEpNPhFYeJ1Bav7ts5HDGfLf7RhZZ9KhpYKEXyKFiCBO2QVj3ei8cVHrac2hhQrGEp6jrF6jRjfLgIPwqtGqeCZ22JyrN8mMo/c0SSJoTFTYjjBOsYPi9EZE3PSs+qEXIjvpu39vZ2bS7NL1/Clhl7cLin+KEsUM09ztW/d2a6p98YrDfqfHh9TlYcKfx8e7GvT8c0663YO+R0HMkuLaA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QqIRBBHbVzEgKXHVrvET1Ga+lWfec6nwIji0dibVU8Tp5XlWyXIkZKodBLEaDfbwqsuGH9PKO7hIRPi1rB2qdHEqkbpl9T+WNKNCgOY6Z5sgO7jtGhWJ7ApJPS/0SP4geLFLgyWDD7MOoxhh/RtTvTEd0GU08stLivwnE2Y/vtL/BLx85q4BmOXTZ8fGy3dlqSNvQDZWCTGJLwOfKLuiRSK2Anebw6Dkgx7HICnmnTjaAq4EA6Dn9E0OQ/RTBr4hDd9X+3zRaeeqjdJTGC9XPk8daB7KhUWZNnMsdRvgeYVvkaB1oTHI/GFgca0Sat237OUdQ0ACYQ15TMTOiSahBQ==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 18 Jan 2021 13:27:31 +0000
  • Ironport-sdr: tyb4sMb/j0ApKo7yjjtk3c1Lpv8HQqm6R0tOMJgfShxO0vABLP054zFbItZbjNZJiA7ZPuWyZ5 r0Qa9KQtC6MINqAZLrjB/idpBp52pVc4SvuCNi+e0bA7LrF61egOqC9KIUNBp9tRCIPpliht1M KWTV62lwaQyACJfeldu0LRZD3VMNhhyo/NB9nYGekwGy+5Y4cZeiZ5FrN142p/OHJBbpEn+vVv DWkW7ou88UVVLXglGzEPN0UGfgQdyArs7ruQhkGHGpg3FbmEDVCg1trDxFzDtzOCBbigLh3LEP hW8=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@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);




 


Rackspace

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