]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/cephfs: fix missing terminating NULL char in readlink()'s C string
authorTuan Hoang <tmhoang@linux.ibm.com>
Tue, 1 Dec 2020 10:57:33 +0000 (11:57 +0100)
committerTuan Hoang <tmhoang@linux.ibm.com>
Mon, 7 Dec 2020 11:22:54 +0000 (06:22 -0500)
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>
src/pybind/cephfs/cephfs.pyx

index c40c2eb06002850b36fd02de591be0ef77cfdca8..249b4ffd057d6e42220f81e9d92fff6322fc345c 100644 (file)
@@ -2167,7 +2167,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)