]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/cephfs: fix missing terminating NULL char in readlink()'s C string 38894/head
authorTuan Hoang <tmhoang@linux.ibm.com>
Tue, 1 Dec 2020 10:57:33 +0000 (11:57 +0100)
committerNathan Cutler <ncutler@suse.com>
Wed, 13 Jan 2021 19:21:07 +0000 (20:21 +0100)
The error is in test_readlink() in src/test/pybind/test_cephfs.py:

...
test_cephfs.test_readlink ... FAIL

======================================================================
FAIL: test_cephfs.test_readlink
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/tmhoang/test_cephfs.py", line 99, in test_readlink
    assert_equal(d, b"/file-1")
AssertionError: b'/file-1\xe8' != b'/file-1'
...

Fixes: https://tracker.ceph.com/issues/48408
Signed-off-by: Tuan Hoang <tmhoang@linux.ibm.com>
(cherry picked from commit b7af5152c1be806fd529242411b9583fd4d50c76)

src/pybind/cephfs/cephfs.pyx

index d7d0c51e451133ebc09e54df84d1802ad584fbd2..9fcf187ea82ff6f267ee7f5883a09c4dbc60801e 100644 (file)
@@ -1401,7 +1401,7 @@ cdef class LibCephFS(object):
                 ret = ceph_readlink(self.cluster, _path, buf, _size)
             if ret < 0:
                 raise make_ex(ret, "error in readlink")
-            return buf
+            return buf[:ret]
         finally:
             free(buf)