From: Olaf Hering Date: Thu, 1 Jul 2021 09:56:00 +0000 (+0200) Subject: tools/python: handle libxl__physmap_info.name properly in convert-legacy-stream X-Git-Tag: archive/raspbian/4.14.3-1+rpi1^2~44^2~35 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f6aec84fe7076d03ac8509de97275e9ef3da37cd;p=xen.git tools/python: handle libxl__physmap_info.name properly in convert-legacy-stream 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 Reviewed-by: Andrew Cooper Acked-by: Marek Marczykowski-Górecki (cherry picked from commit c8f88810db2a25d6aacf65c1c60bc4f5d848a483) --- diff --git a/tools/python/scripts/convert-legacy-stream b/tools/python/scripts/convert-legacy-stream index 66ee3d2f5d..227e1b5c3f 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, )