]> 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>
Sun, 21 Sep 2014 12:33:05 +0000 (14:33 +0200)
Read data may contain \0, and buf.value interprerts them as string terminator.

Signed-off-by: Mohammad Salehe <salehe+dev@gmail.com>
(cherry picked from commit 8bda44ff37fd04a0fc9498fbbc22f0daf515d721)

src/pybind/rados.py

index e5da0771771ae5eb47b698ccbb85e14d667286aa..0fbd10e64a10aed5fec5098ffd0bc55c6af8a47c 100644 (file)
@@ -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),