kdc: add _nocopy setter for use by mssfu

Add an internal-use setter accessor for use by mssfu.c when principal names are
replaced. This also fixes a leak where r->client_princ was not freed before
being replaced with the impersonated client name.
This commit is contained in:
Luke Howard
2022-01-20 15:26:50 +11:00
parent ec24edf700
commit e32f7a4387
3 changed files with 75 additions and 37 deletions

View File

@@ -493,3 +493,35 @@ free_keyblock(EncryptionKey *key)
#undef HEIMDAL_KDC_KDC_ACCESSORS_H
#include "kdc-accessors.h"
#undef _KDC_REQUEST_GET_ACCESSOR
#undef _KDC_REQUEST_SET_ACCESSOR
#undef _KDC_REQUEST_GET_ACCESSOR_PTR
#undef _KDC_REQUEST_SET_ACCESSOR_PTR
#define _KDC_REQUEST_SET_ACCESSOR_PTR(R, T, t, f) \
void \
_kdc_request_set_ ## f ## _nocopy(R r, T *v) \
{ \
if (*v != r->f) { \
free_##t(r->f); \
r->f = *v; \
} \
*v = NULL; \
}
#undef _KDC_REQUEST_GET_ACCESSOR_STRUCT
#undef _KDC_REQUEST_SET_ACCESSOR_STRUCT
#define _KDC_REQUEST_SET_ACCESSOR_STRUCT(R, T, t, f) \
void \
_kdc_request_set_ ## f ## _nocopy(R r, T *v) \
{ \
if (v != &r->f) { \
free_##t(&r->f); \
r->f = *v; \
} \
memset(v, 0, sizeof(*v)); \
}
#undef HEIMDAL_KDC_KDC_ACCESSORS_H
#include "kdc-accessors.h"