[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v20210701 05/40] tools: 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.4 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 the cstring is unpacked into the actual string and the trailing nil. Signed-off-by: Olaf Hering <olaf@xxxxxxxxx> --- tools/python/scripts/convert-legacy-stream | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/python/scripts/convert-legacy-stream b/tools/python/scripts/convert-legacy-stream index 66ee3d2f5d..9003ac4f6d 100755 --- a/tools/python/scripts/convert-legacy-stream +++ b/tools/python/scripts/convert-legacy-stream @@ -336,20 +336,21 @@ def read_libxl_toolstack(vm, data): if len(data) < namelen: raise StreamError("Remaining data too short for physmap name") - name = data[:namelen] + c_string = data[:namelen] data = data[namelen:] # Strip padding off the end of name if twidth == 64: - name = name[:-4] + c_string = c_string[:-4] - if name[-1] != b'\x00': + name, nil = unpack("={0}sB".format(len(c_string) - 1), c_string) + if nil != 0: raise StreamError("physmap name not NUL terminated") root = b"physmap/%x" % (phys, ) kv = [root + b"/start_addr", b"%x" % (start, ), root + b"/size", b"%x" % (size, ), - root + b"/name", name[:-1]] + root + b"/name", name] for key, val in zip(kv[0::2], kv[1::2]): info(" '%s' = '%s'" % (key.decode(), val.decode()))
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |