From ffb07736ff6149278cce1a5ab3714a98a04591b3 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Mon, 26 Jun 2006 22:04:51 +0000 Subject: [PATCH] * src/lib/krb5_32.def: Export krb5_copy_context * src/lib/krb5/libkrb5.exports: Export krb5_copy_context. * src/lib/krb5/krb/init_ctx.c (krb5_copy_context): Fix malloc argument for nctx. Handle null default_ccname case. ticket: 2856 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18229 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/init_ctx.c | 16 +++++++++++----- src/lib/krb5/libkrb5.exports | 1 + src/lib/krb5_32.def | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/lib/krb5/krb/init_ctx.c b/src/lib/krb5/krb/init_ctx.c index 85a3d144a..8e4ce8c3b 100644 --- a/src/lib/krb5/krb/init_ctx.c +++ b/src/lib/krb5/krb/init_ctx.c @@ -516,7 +516,10 @@ krb5_copy_context(krb5_context ctx, krb5_context *nctx_out) if (ctx == NULL) return EINVAL; /* XXX */ - nctx = malloc(sizeof(krb5_context*)); + nctx = malloc(sizeof(*nctx)); + if (nctx == NULL) + return ENOMEM; + *nctx = *ctx; nctx->in_tkt_ktypes = NULL; @@ -549,10 +552,13 @@ krb5_copy_context(krb5_context ctx, krb5_context *nctx_out) goto errout; nctx->tgs_ktype_count = ctx->tgs_ktype_count; - nctx->os_context->default_ccname = strdup(ctx->os_context->default_ccname); - if (nctx->os_context->default_ccname == NULL) { - ret = ENOMEM; - goto errout; + if (ctx->os_context->default_ccname != NULL) { + nctx->os_context->default_ccname = + strdup(ctx->os_context->default_ccname); + if (nctx->os_context->default_ccname == NULL) { + ret = ENOMEM; + goto errout; + } } ret = krb5_get_profile(ctx, &nctx->profile); if (ret) diff --git a/src/lib/krb5/libkrb5.exports b/src/lib/krb5/libkrb5.exports index b2fd14e57..94e94e45d 100644 --- a/src/lib/krb5/libkrb5.exports +++ b/src/lib/krb5/libkrb5.exports @@ -323,6 +323,7 @@ krb5_copy_addresses krb5_copy_authdata krb5_copy_authenticator krb5_copy_checksum +krb5_copy_context krb5_copy_creds krb5_copy_data krb5_copy_keyblock diff --git a/src/lib/krb5_32.def b/src/lib/krb5_32.def index db0be8c61..9785df563 100644 --- a/src/lib/krb5_32.def +++ b/src/lib/krb5_32.def @@ -100,6 +100,7 @@ krb5_c_string_to_key_with_params krb5_copy_authdata krb5_copy_authenticator krb5_copy_checksum + krb5_copy_context krb5_copy_creds krb5_copy_data krb5_copy_keyblock -- 2.26.2