From 2d4381e9cd1f20d677446b9ee4924c4a97ce7e80 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Wed, 9 Jan 1991 00:35:04 +0000 Subject: [PATCH] Robustified copy_authenticator so that the passed in authenticator can have a NULL subkey or checksum. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1625 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/copy_athctr.c | 39 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/lib/krb5/krb/copy_athctr.c b/src/lib/krb5/krb/copy_athctr.c index 5f30ac4af..5756a991c 100644 --- a/src/lib/krb5/krb/copy_athctr.c +++ b/src/lib/krb5/krb/copy_athctr.c @@ -37,26 +37,29 @@ krb5_authenticator **authto; return retval; } - if (retval = krb5_copy_checksum(authfrom->checksum, &tempto->checksum)) { - krb5_free_principal(tempto->client); - xfree(tempto); - return retval; + if (authfrom->checksum && + (retval = krb5_copy_checksum(authfrom->checksum, &tempto->checksum))) { + krb5_free_principal(tempto->client); + xfree(tempto); + return retval; } - if (!(tempto->subkey = - (krb5_keyblock *)malloc(sizeof(*tempto->subkey)))) { - krb5_free_checksum(tempto->checksum); - krb5_free_principal(tempto->client); - xfree(tempto); - return ENOMEM; - } - if (retval = krb5_copy_keyblock(authfrom->subkey, - tempto->subkey)) { - xfree(tempto->subkey); - krb5_free_checksum(tempto->checksum); - krb5_free_principal(tempto->client); - xfree(tempto); - return retval; + if (authfrom->subkey) { + if (!(tempto->subkey = + (krb5_keyblock *)malloc(sizeof(*tempto->subkey)))) { + krb5_free_checksum(tempto->checksum); + krb5_free_principal(tempto->client); + xfree(tempto); + return ENOMEM; + } + if (retval = krb5_copy_keyblock(authfrom->subkey, + tempto->subkey)) { + xfree(tempto->subkey); + krb5_free_checksum(tempto->checksum); + krb5_free_principal(tempto->client); + xfree(tempto); + return retval; + } } *authto = tempto; -- 2.26.2