dl + getenv (without arguments) = segfault (python2.p2, python2.3)

Skip Montanaro skip at pobox.com
Thu Aug 7 01:49:12 CEST 2003


    import dl

    a=dl.open("libc.so.6")
    print a.call("getenv")

    sabu> Now, my problem is not with the obvious.. but with the fact that
    sabu> Python segfaulted instead of raising an exception or returning 0

Just because a.call() can call getenv() indirectly doesn't absolve you of
the responsibility of calling it with the right arguments.  Python has no
way of knowing the prototype of getenv().  The dl module is one of those
"dangerous" modules.  It gives you the ability to make essentially unchecked
calls directly to C code.

Skip





More information about the Python-list mailing list