Skip to content

Commit 4b828ce

Browse files
committed
Avoid NULL dereference of 'actual_mech_type'
The actual_mech is not promised till we complet the context. This fix a segfault when creating a SecurityContext with SPNEGO mech.
1 parent 21ae06b commit 4b828ce

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gssapi/raw/sec_contexts.pyx

+4-2
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ flags=None, lifetime=None, channel_bindings=None, input_token=None)
204204
input_token_buffer.value = input_token
205205
input_token_buffer.length = len(input_token)
206206

207-
cdef gss_OID actual_mech_type
207+
cdef gss_OID actual_mech_type = GSS_C_NO_OID;
208208
cdef gss_buffer_desc output_token_buffer = gss_buffer_desc(0, NULL)
209209
cdef OM_uint32 ret_flags
210210
cdef OM_uint32 output_ttl
@@ -232,7 +232,9 @@ flags=None, lifetime=None, channel_bindings=None, input_token=None)
232232

233233
cdef OID output_mech_type = OID()
234234
if maj_stat == GSS_S_COMPLETE or maj_stat == GSS_S_CONTINUE_NEEDED:
235-
output_mech_type.raw_oid = actual_mech_type[0]
235+
if actual_mech_type:
236+
output_mech_type.raw_oid = actual_mech_type[0]
237+
236238
return InitSecContextResult(output_context, output_mech_type,
237239
IntEnumFlagSet(RequirementFlag, ret_flags),
238240
output_token,

0 commit comments

Comments
 (0)