[Bugs] [Bug 1450593] New: Gluster Python scripts do not check return value of find_library

bugzilla at redhat.com bugzilla at redhat.com
Sat May 13 14:30:41 UTC 2017


https://bugzilla.redhat.com/show_bug.cgi?id=1450593

            Bug ID: 1450593
           Summary: Gluster Python scripts do not check return value of
                    find_library
           Product: GlusterFS
           Version: 3.10
         Component: core
          Assignee: bugs at gluster.org
          Reporter: nh2-redhatbugzilla at deditus.de
                CC: bugs at gluster.org



Gluster 3.10.1.

In many places, the gluster Pyton scripts, such as libgfchangelog.py (see
https://github.com/gluster/glusterfs/blob/v3.10.1/geo-replication/syncdaemon/libgfchangelog.py#L18)
use the pattern:

libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL, use_errno=True)

This is improper error handling: You're supposed to check the return value of
`find_library("yourlib")`. It can be `None`, which means the library was not
found.

This can happen for packaging, messed up paths like in #1450588, wrong
LD_LIBRARY_PATH, and so on.

CDLL also accepts `None` as first argument without throwing an exception, so
the code just continues to run with a library that doesn't exist instead of
failing early.

For exmaple, `cdll.LoadLibrary(find_library("nonexistent"))` returns a handle
`<CDLL 'None', handle 7f4c46dac168 at 7f4c426fac50>`.

Gluster should check the return value of all find_library() calls, and error on
failure.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.


More information about the Bugs mailing list