xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
	Olaf Hering <olaf@aepfle.de>, Juergen Gross <jgross@suse.com>,
	Ian Jackson <iwj@xenproject.org>, Wei Liu <wl@xen.org>
Subject: Re: [PATCH 1/5] tools/python: handle libxl__physmap_info.name properly in convert-legacy-stream
Date: Mon, 5 Jul 2021 21:49:52 +0200	[thread overview]
Message-ID: <YONiYGQAaj9oSHnt@mail-itl> (raw)
In-Reply-To: <20210705191027.15107-2-andrew.cooper3@citrix.com>

[-- Attachment #1: Type: text/plain, Size: 1617 bytes --]

On Mon, Jul 05, 2021 at 08:10:23PM +0100, Andrew Cooper wrote:
> From: Olaf Hering <olaf@aepfle.de>
> 
> The trailing member name[] in libxl__physmap_info is written as a
> cstring into the stream. The current code does a sanity check if the
> last byte is zero. This attempt fails with python3 because name[-1]
> returns a type int. As a result the comparison with byte(\00) fails:
> 
>   File "/usr/lib/xen/bin/convert-legacy-stream", line 347, in read_libxl_toolstack
>     raise StreamError("physmap name not NUL terminated")
>   StreamError: physmap name not NUL terminated
> 
> To handle both python variants, cast to bytearray().
> 
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

> ---
>  tools/python/scripts/convert-legacy-stream | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/python/scripts/convert-legacy-stream b/tools/python/scripts/convert-legacy-stream
> index 66ee3d2f5d29..227e1b5c3fd3 100755
> --- a/tools/python/scripts/convert-legacy-stream
> +++ b/tools/python/scripts/convert-legacy-stream
> @@ -343,7 +343,7 @@ def read_libxl_toolstack(vm, data):
>          if twidth == 64:
>              name = name[:-4]
>  
> -        if name[-1] != b'\x00':
> +        if bytearray(name)[-1] != 0:
>              raise StreamError("physmap name not NUL terminated")
>  
>          root = b"physmap/%x" % (phys, )
> -- 
> 2.11.0
> 

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2021-07-05 19:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05 19:10 [PATCH 0/5] tools/migration: Py3 fixes, and page type helpers Andrew Cooper
2021-07-05 19:10 ` [PATCH 1/5] tools/python: handle libxl__physmap_info.name properly in convert-legacy-stream Andrew Cooper
2021-07-05 19:49   ` Marek Marczykowski-Górecki [this message]
2021-07-05 19:10 ` [PATCH 2/5] tools/python: fix Python3.4 TypeError in format string Andrew Cooper
2021-07-05 19:51   ` Marek Marczykowski-Górecki
2021-07-05 19:10 ` [PATCH 3/5] tools/migration: unify known page type checking Andrew Cooper
2021-07-05 19:10 ` [PATCH 4/5] tools/migration: unify type checking for data pfns in the VM Andrew Cooper
2021-07-05 19:10 ` [PATCH 5/5] tools/migration: unify type checking for data pfns in migration stream Andrew Cooper
2021-07-06  4:57   ` Juergen Gross
2021-07-06  7:11 ` [PATCH 0/5] tools/migration: Py3 fixes, and page type helpers Olaf Hering

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=YONiYGQAaj9oSHnt@mail-itl \
    --to=marmarek@invisiblethingslab.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jgross@suse.com \
    --cc=olaf@aepfle.de \
    --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 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).