mirror of https://github.com/FreeRDP/FreeRDP
[kerberos] Assert expected pointer arguments
This commit is contained in:
parent
3ffc32176d
commit
e4b82cf0ef
|
@ -21,10 +21,13 @@
|
|||
|
||||
#include <winpr/endian.h>
|
||||
#include <winpr/wlog.h>
|
||||
#include <winpr/assert.h>
|
||||
#include "krb5glue.h"
|
||||
|
||||
void krb5glue_keys_free(krb5_context ctx, struct krb5glue_keyset* keyset)
|
||||
{
|
||||
if (!ctx || !keyset)
|
||||
return;
|
||||
if (keyset->session_key)
|
||||
krb5_crypto_destroy(ctx, keyset->session_key);
|
||||
if (keyset->initiator_key)
|
||||
|
@ -39,6 +42,10 @@ krb5_error_code krb5glue_update_keyset(krb5_context ctx, krb5_auth_context auth_
|
|||
krb5_keyblock* keyblock = NULL;
|
||||
krb5_error_code rv = 0;
|
||||
|
||||
WINPR_ASSERT(ctx);
|
||||
WINPR_ASSERT(auth_ctx);
|
||||
WINPR_ASSERT(keyset);
|
||||
|
||||
krb5glue_keys_free(ctx, keyset);
|
||||
|
||||
if (!(rv = krb5_auth_con_getkey(ctx, auth_ctx, &keyblock)))
|
||||
|
@ -78,7 +85,13 @@ krb5_error_code krb5glue_verify_checksum_iov(krb5_context ctx, krb5glue_key key,
|
|||
krb5_crypto_iov* iov, unsigned int iov_size,
|
||||
krb5_boolean* is_valid)
|
||||
{
|
||||
krb5_error_code rv = krb5_verify_checksum_iov(ctx, key, usage, iov, iov_size, NULL);
|
||||
krb5_error_code rv = 0;
|
||||
|
||||
WINPR_ASSERT(ctx);
|
||||
WINPR_ASSERT(key);
|
||||
WINPR_ASSERT(is_valid);
|
||||
|
||||
rv = krb5_verify_checksum_iov(ctx, key, usage, iov, iov_size, NULL);
|
||||
*is_valid = (rv == 0);
|
||||
return rv;
|
||||
}
|
||||
|
@ -88,6 +101,11 @@ krb5_error_code krb5glue_crypto_length(krb5_context ctx, krb5glue_key key, int t
|
|||
{
|
||||
krb5_error_code rv = 0;
|
||||
size_t s = 0;
|
||||
|
||||
WINPR_ASSERT(ctx);
|
||||
WINPR_ASSERT(key);
|
||||
WINPR_ASSERT(size);
|
||||
|
||||
rv = krb5_crypto_length(ctx, key, type, &s);
|
||||
*size = (UINT)s;
|
||||
return rv;
|
||||
|
@ -98,6 +116,10 @@ krb5_error_code krb5glue_log_error(krb5_context ctx, krb5_data* msg, const char*
|
|||
krb5_error error = { 0 };
|
||||
krb5_error_code rv = 0;
|
||||
|
||||
WINPR_ASSERT(ctx);
|
||||
WINPR_ASSERT(msg);
|
||||
WINPR_ASSERT(tag);
|
||||
|
||||
if (!(rv = krb5_rd_error(ctx, msg, &error)))
|
||||
{
|
||||
WLog_ERR(tag, "KRB_ERROR: %" PRIx32, error.error_code);
|
||||
|
@ -109,6 +131,8 @@ krb5_error_code krb5glue_log_error(krb5_context ctx, krb5_data* msg, const char*
|
|||
BOOL krb5glue_authenticator_validate_chksum(krb5glue_authenticator authenticator, int cksumtype,
|
||||
uint32_t* flags)
|
||||
{
|
||||
WINPR_ASSERT(flags);
|
||||
|
||||
if (!authenticator || !authenticator->cksum || authenticator->cksum->cksumtype != cksumtype ||
|
||||
authenticator->cksum->checksum.length < 24)
|
||||
return FALSE;
|
||||
|
@ -126,6 +150,8 @@ krb5_error_code krb5glue_get_init_creds(krb5_context ctx, krb5_principal princ,
|
|||
krb5_init_creds_context creds_ctx = NULL;
|
||||
krb5_creds creds = { 0 };
|
||||
|
||||
WINPR_ASSERT(ctx);
|
||||
|
||||
krb5_get_init_creds_opt_alloc(ctx, &gic_opt);
|
||||
|
||||
krb5_get_init_creds_opt_set_forwardable(gic_opt, 0);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <winpr/endian.h>
|
||||
#include <winpr/crypto.h>
|
||||
#include <winpr/print.h>
|
||||
#include <winpr/assert.h>
|
||||
#include <errno.h>
|
||||
#include "krb5glue.h"
|
||||
#include <profile.h>
|
||||
|
@ -43,6 +44,9 @@ static char* create_temporary_file(void)
|
|||
|
||||
void krb5glue_keys_free(krb5_context ctx, struct krb5glue_keyset* keyset)
|
||||
{
|
||||
WINPR_ASSERT(ctx);
|
||||
WINPR_ASSERT(keyset);
|
||||
|
||||
krb5_k_free_key(ctx, keyset->session_key);
|
||||
krb5_k_free_key(ctx, keyset->initiator_key);
|
||||
krb5_k_free_key(ctx, keyset->acceptor_key);
|
||||
|
@ -51,6 +55,10 @@ void krb5glue_keys_free(krb5_context ctx, struct krb5glue_keyset* keyset)
|
|||
krb5_error_code krb5glue_update_keyset(krb5_context ctx, krb5_auth_context auth_ctx, BOOL acceptor,
|
||||
struct krb5glue_keyset* keyset)
|
||||
{
|
||||
WINPR_ASSERT(ctx);
|
||||
WINPR_ASSERT(auth_ctx);
|
||||
WINPR_ASSERT(keyset);
|
||||
|
||||
krb5glue_keys_free(ctx, keyset);
|
||||
krb5_auth_con_getkey_k(ctx, auth_ctx, &keyset->session_key);
|
||||
if (acceptor)
|
||||
|
@ -68,6 +76,9 @@ krb5_error_code krb5glue_update_keyset(krb5_context ctx, krb5_auth_context auth_
|
|||
|
||||
krb5_prompt_type krb5glue_get_prompt_type(krb5_context ctx, krb5_prompt prompts[], int index)
|
||||
{
|
||||
WINPR_ASSERT(ctx);
|
||||
WINPR_ASSERT(prompts);
|
||||
|
||||
krb5_prompt_type* types = krb5_get_prompt_types(ctx);
|
||||
return types ? types[index] : 0;
|
||||
}
|
||||
|
@ -77,6 +88,10 @@ krb5_error_code krb5glue_log_error(krb5_context ctx, krb5_data* msg, const char*
|
|||
krb5_error* error = NULL;
|
||||
krb5_error_code rv = 0;
|
||||
|
||||
WINPR_ASSERT(ctx);
|
||||
WINPR_ASSERT(msg);
|
||||
WINPR_ASSERT(tag);
|
||||
|
||||
if (!(rv = krb5_rd_error(ctx, msg, &error)))
|
||||
{
|
||||
WLog_ERR(tag, "KRB_ERROR: %s", error->text.data);
|
||||
|
@ -89,6 +104,8 @@ krb5_error_code krb5glue_log_error(krb5_context ctx, krb5_data* msg, const char*
|
|||
BOOL krb5glue_authenticator_validate_chksum(krb5glue_authenticator authenticator, int cksumtype,
|
||||
uint32_t* flags)
|
||||
{
|
||||
WINPR_ASSERT(flags);
|
||||
|
||||
if (!authenticator || !authenticator->checksum ||
|
||||
authenticator->checksum->checksum_type != cksumtype || authenticator->checksum->length < 24)
|
||||
return FALSE;
|
||||
|
@ -107,6 +124,8 @@ krb5_error_code krb5glue_get_init_creds(krb5_context ctx, krb5_principal princ,
|
|||
char* tmp_profile_path = create_temporary_file();
|
||||
profile_t profile = NULL;
|
||||
|
||||
WINPR_ASSERT(ctx);
|
||||
|
||||
krb5_get_init_creds_opt_alloc(ctx, &gic_opt);
|
||||
|
||||
krb5_get_init_creds_opt_set_forwardable(gic_opt, 0);
|
||||
|
|
Loading…
Reference in New Issue