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

[PATCH 1/5] tools/python: handle libxl__physmap_info.name properly in convert-legacy-stream


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 5 Jul 2021 20:10:23 +0100
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Olaf Hering <olaf@xxxxxxxxx>, "Juergen Gross" <jgross@xxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 05 Jul 2021 19:11:01 +0000
  • Ironport-hdrordr: A9a23:VLwU6KzZNyrW7ofCxFmTKrPwOr1zdoMgy1knxilNoRw8SKKlfq GV7ZMmPHDP6Ar5NEtNpTniAtjlfZq/z+8X3WB5B97LN2OKhILBFvAG0WKI+Vzd8kPFmdK1rZ 0QEZRDNA==
  • Ironport-sdr: kL+M67rezHidGYQ6Vr9YydkTRy00f8MtKIghQVumW8qNZnK8NSA449qEQuOij4TiFUa+PoT51S X9ZXuoWbMdekZzyQ6WLj41ufMthLif2sgMw8mriqQ4/v2enKDxzKHSARXCgUu5KOUDzNNm9KOq 6ZE6mMB5zzNxyzWTOG2S78ifqIGHlXmioZgv8eBmFEeuvynQFdpyDGuaSWVkYHMJRgf7ijzzbs zQhugJxMouo916tmFJjk7PQAs0D6wuO/OMpr/DiIX/wpF4TvJA4t7co8I1ZICGpoQ8pnRHTT20 u3Y=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Olaf Hering <olaf@xxxxxxxxx>

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@xxxxxxxxx>
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 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




 


Rackspace

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