krb5: fix output_token allocators in the GSS debug stub (Windows)
#19064
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this patch system
malloc()/free()were used to allocatethe buffer returned in the
output_tokenobject from the debug stubof
gss_init_sec_context()when enabled viaCURL_STUB_GSS_CREDSindebug-enabled libcurl builds. This object is later released via stock
gss_release_buffer(), which, in the Windows builds of MIT Kerberos,doesn't use the system
free(), but the Win32HeapFree().Fix it by using the GSS alloc/free macros:
gssalloc_malloc()andgssalloc_free()fromgssapi_alloc.h.To make this work without MIT Kerberos feature detection, use a canary
macro to detect a version which installs
gssapi_alloc.hfor Windows.For <1.15 (2016-11-30) releases, that do not install it, disable the GSS
debug stub in libcurl.
Strictly speaking, non-Windows builds would also need to use GSS
allocators, but, detecting support for
gssapi_alloc.his impossiblewithout build-level logic. Built-level logic is complex and overkill,
and MIT Kerberos, as of 1.22.1, uses standard malloc/free on
non-Windows platforms anyway. (except in GSS debug builds.)
Follow-up to 7384083 #17752
DEBUGBUILDstub feature with <1.18.
I haven't actually tested this with a Windows build, which is also missing
from CI at the moment.