From: Tuan Hoang Date: Tue, 1 Dec 2020 10:57:33 +0000 (+0100) Subject: pybind/cephfs: fix missing terminating NULL char in readlink()'s C string X-Git-Tag: v15.2.9~28^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=586aefcd31454e49fc8b371e014a03d079d40a5a;p=ceph.git pybind/cephfs: fix missing terminating NULL char in readlink()'s C string 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 (cherry picked from commit b7af5152c1be806fd529242411b9583fd4d50c76) --- diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index efe8a3e6db2..04c9cca767c 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -1482,7 +1482,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)