apple / ccs-pykerberos

Python Kerberos library used by CalendarServer
https://www.calendarserver.org
Apache License 2.0
117 stars 65 forks source link

PyCapsule_SetPointer called with null pointer (breaks PyKerberos under python 3.x) #48

Closed macosforgebot closed 6 years ago

macosforgebot commented 8 years ago

bernie.hackett@… originally submitted this as ticket:936


Both authGSSClientClean and authGSSServerClean call PyCObject_SetVoidPtr(pystate, NULL). When built for python 3.x PyCObject_SetVoidPtr is aliased as PyCapsule_SetPointer. According to The C API docs, the second parameter to PyCapsule_SetPointer cannot be NULL:

https://docs.python.org/3.1/c-api/capsule.html#PyCapsule_SetPointer

Reproduction:

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import kerberos res, ctx = kerberos.authGSSClientInit("someservice@somehost") kerberos.authGSSClientClean(ctx)

1

res, ctx = kerberos.authGSSClientInit("someservice@somehost")

ValueError: PyCapsule_SetPointer called with null pointer

This makes PyKerberos unusable under python 3.

macosforgebot commented 8 years ago

bernie.hackett@… originally submitted this as comment:1:⁠ticket:936


One solution to this problem would be to make authGSSClientClean and authGSSServerClean obsolete. PyCObject_FromVoidPointer and PyCapsule_New both take a destructor argument. The destructor is called when the PyCObject / PyCapsule is reclaimed. See this github fork for an example:

https://github.com/02strich/pykerberos/blob/master/src/kerberos.c