From: Greg Hudson Date: Mon, 21 Oct 2019 14:29:35 +0000 (-0400) Subject: Fix gssalloc_realloc() on Windows X-Git-Tag: krb5-1.18-beta1~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F990%2Fhead;p=thirdparty%2Fkrb5.git 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. ticket: 8735 tags: pullup target_version: 1.17-next --- diff --git a/src/lib/gssapi/generic/gssapi_alloc.h b/src/lib/gssapi/generic/gssapi_alloc.h index 9a5cd9892c..fff88fd44a 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); }