From 72a46dec211d5c08d1ca9f969013d939c4361ba9 Mon Sep 17 00:00:00 2001 From: Mohammad Salehe Date: Sun, 25 May 2014 10:42:11 +0430 Subject: [PATCH] pybind: Fix aio_read handling of string buffer Read data may contain \0, and buf.value interprerts them as string terminator. Signed-off-by: Mohammad Salehe (cherry picked from commit 8bda44ff37fd04a0fc9498fbbc22f0daf515d721) --- src/pybind/rados.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pybind/rados.py b/src/pybind/rados.py index e5da0771771ae..0fbd10e64a10a 100644 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -1089,8 +1089,11 @@ class Ioctx(object): :returns: completion object """ buf = create_string_buffer(length) - def oncomplete_(completion): - return oncomplete(completion, buf.value) + def oncomplete_(completion_v): + return_value = completion_v.get_return_value() + return oncomplete(completion_v, + ctypes.string_at(buf, return_value) if return_value >= 0 else None) + completion = self.__get_completion(oncomplete_, None) ret = run_in_thread(self.librados.rados_aio_read, (self.io, c_char_p(object_name), -- 2.39.5