Add freerdp_nla_FreeContextBuffer()

This function should be used to free certain buffers retrieved using
freerdp_nla_QueryContextAttributes(). It fetches the right vfunc table
to call into, which typically ends up in sspi_FreeContextBuffer() in
sspi_winpr.c.

This is needed to allow querying the PackageInfo attribute.
This commit is contained in:
Jonas Ådahl
2026-01-22 11:01:20 +01:00
parent e327d97c59
commit e6aa564bd7
4 changed files with 37 additions and 0 deletions

View File

@@ -767,6 +767,17 @@ owned by rdpRdp */
FREERDP_API SECURITY_STATUS freerdp_nla_QueryContextAttributes(rdpContext* context,
DWORD ulAttr, PVOID pBuffer);
/** Calls FreeContextbuffer on the SSPI context associated with the NLA part of the RDP context
*
* \param context the RDP context
* \param pBuffer an opaque pointer to free
* \returns a SECURITY_STATUS indicating if the operation completed successfully
* \since version 3.22.0
*
* Supported buffers are ones retrieved from SECPKG_ATTR_PACKAGE_INFO.
*/
FREERDP_API SECURITY_STATUS freerdp_nla_FreeContextBuffer(rdpContext* context, PVOID pBuffer);
FREERDP_API void clearChannelError(rdpContext* context);
FREERDP_API HANDLE getChannelErrorEventHandle(rdpContext* context);
FREERDP_API UINT getChannelError(const rdpContext* context);

View File

@@ -1349,6 +1349,20 @@ SECURITY_STATUS freerdp_nla_QueryContextAttributes(rdpContext* context, DWORD ul
return nla_QueryContextAttributes(nla, ulAttr, pBuffer);
}
SECURITY_STATUS freerdp_nla_FreeContextBuffer(rdpContext* context, PVOID pBuffer)
{
WINPR_ASSERT(context);
WINPR_ASSERT(context->rdp);
rdpNla* nla = context->rdp->nla;
if (!nla)
nla = transport_get_nla(context->rdp->transport);
WINPR_ASSERT(nla);
return nla_FreeContextBuffer(nla, pBuffer);
}
HANDLE getChannelErrorEventHandle(rdpContext* context)
{
WINPR_ASSERT(context);

View File

@@ -2455,3 +2455,14 @@ SECURITY_STATUS nla_QueryContextAttributes(rdpNla* nla, DWORD ulAttr, PVOID pBuf
return table->QueryContextAttributes(&context, ulAttr, pBuffer);
}
SECURITY_STATUS nla_FreeContextBuffer(rdpNla* nla, PVOID pBuffer)
{
WINPR_ASSERT(nla);
SecurityFunctionTable* table = NULL;
CtxtHandle context = { 0 };
credssp_auth_tableAndContext(nla->auth, &table, &context);
return table->FreeContextBuffer(pBuffer);
}

View File

@@ -78,5 +78,6 @@ FREERDP_LOCAL void nla_set_early_user_auth(rdpNla* nla, BOOL earlyUserAuth);
FREERDP_LOCAL BOOL nla_encrypt(rdpNla* nla, const SecBuffer* inBuffer, SecBuffer* outBuffer);
FREERDP_LOCAL BOOL nla_decrypt(rdpNla* nla, const SecBuffer* inBuffer, SecBuffer* outBuffer);
FREERDP_LOCAL SECURITY_STATUS nla_QueryContextAttributes(rdpNla* nla, DWORD ulAttr, PVOID pBuffer);
FREERDP_LOCAL SECURITY_STATUS nla_FreeContextBuffer(rdpNla* nla, PVOID pBuffer);
#endif /* FREERDP_LIB_CORE_NLA_H */