aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2019-10-21 10:29:35 -0400
committerGreg Hudson <ghudson@mit.edu>2019-12-09 17:02:52 -0500
commitc1f08b6ff1b3988da72e64093e9818f15c83619f (patch)
tree3aa3a4ef722ceb5a721b38e466840df2cb8c605c
parent0d35a5fe8a42b360d70ed84c15edbf8b7f7995f1 (diff)
downloadkrb5-c1f08b6ff1b3988da72e64093e9818f15c83619f.zip
krb5-c1f08b6ff1b3988da72e64093e9818f15c83619f.tar.gz
krb5-c1f08b6ff1b3988da72e64093e9818f15c83619f.tar.bz2
Fix gssalloc_realloc() on Windows
gss_inquire_sec_context_by_oid(GSS_C_INQ_SSPI_SESSION_KEY) fails on Windows because generic_gss_add_buffer_set_member() relies on the ability to realloc() a null pointer. Unlike realloc(), HeapReAlloc() requires an input pointer that (from the MSDN documentation) "is returned by an earlier call to the HeapAlloc or HeapReAlloc function". So gssalloc_realloc() must test for null inputs and call HeapAlloc() instead. Reported by Eric Pauly. (cherry picked from commit d66b311093f1782c3610bbc77bd78fce411e8f79) ticket: 8735 version_fixed: 1.17.1
-rw-r--r--src/lib/gssapi/generic/gssapi_alloc.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lib/gssapi/generic/gssapi_alloc.h b/src/lib/gssapi/generic/gssapi_alloc.h
index 9a5cd98..fff88fd 100644
--- a/src/lib/gssapi/generic/gssapi_alloc.h
+++ b/src/lib/gssapi/generic/gssapi_alloc.h
@@ -36,6 +36,9 @@ gssalloc_calloc(size_t count, size_t size)
static inline void *
gssalloc_realloc(void *value, size_t size)
{
+ /* Unlike realloc(), HeapReAlloc() does not work on null values. */
+ if (value == NULL)
+ return HeapAlloc(GetProcessHeap(), 0, size);
return HeapReAlloc(GetProcessHeap(), 0, value, size);
}