]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: Fix aio_read handling of string buffer
authorMohammad Salehe <salehe+dev@gmail.com>
Sun, 25 May 2014 06:12:11 +0000 (10:42 +0430)
committerLoic Dachary <loic-201408@dachary.org>
Sat, 20 Sep 2014 10:43:27 +0000 (12:43 +0200)
Read data may contain \0, and buf.value interprerts them as string terminator.

Signed-off-by: Mohammad Salehe <salehe+dev@gmail.com>
src/pybind/rados.py

index f51e7443286268065c44ef2afe429c196414f7cc..93e5040873e8e72e5e1ad3f2485dea78ddeda1bb 100644 (file)
@@ -1085,8 +1085,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),