From 86a23d4be9245838a955c7e1bb557cd14b320962 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Mon, 9 Feb 2009 21:23:00 +0000 Subject: [PATCH] In asn1_k_encode.c, stop inconsistently destroying buf on some errors. It belongs to the caller. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21927 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/asn.1/asn1_k_encode.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/lib/krb5/asn.1/asn1_k_encode.c b/src/lib/krb5/asn.1/asn1_k_encode.c index 1f2cce803..57a83f1f8 100644 --- a/src/lib/krb5/asn.1/asn1_k_encode.c +++ b/src/lib/krb5/asn.1/asn1_k_encode.c @@ -1304,12 +1304,10 @@ MAKE_FULL_ENCODER(encode_krb5_etype_list, etype_list); { unsigned int length; \ retval = encoder(buf,len,value,&length); \ if (retval) {\ - asn1buf_destroy(&buf);\ return retval; }\ sum += length;\ retval = asn1_make_etag(buf,CONTEXT_SPECIFIC,tag,length,&length);\ if (retval) {\ - asn1buf_destroy(&buf);\ return retval; }\ sum += length; } @@ -1402,10 +1400,8 @@ asn1_error_code asn1_encode_algorithm_identifier(asn1buf *buf, const krb5_algori if (val->parameters.length != 0) { retval = asn1buf_insert_octetstring(buf, val->parameters.length, val->parameters.data); - if (retval) { - asn1buf_destroy(&buf); + if (retval) return retval; - } sum += val->parameters.length; } @@ -1415,10 +1411,8 @@ asn1_error_code asn1_encode_algorithm_identifier(asn1buf *buf, const krb5_algori val->algorithm.data, &length); - if (retval) { - asn1buf_destroy(&buf); + if (retval) return retval; - } sum += length; } @@ -1440,20 +1434,16 @@ asn1_error_code asn1_encode_subject_pk_info(asn1buf *buf, const krb5_subject_pk_ retval = asn1buf_insert_octetstring(buf, val->algorithm.parameters.length, val->algorithm.parameters.data); - if (retval) { - asn1buf_destroy(&buf); + if (retval) return retval; - } sum += val->algorithm.parameters.length; retval = asn1_encode_oid(buf, val->algorithm.algorithm.length, val->algorithm.algorithm.data, &length); - if (retval) { - asn1buf_destroy(&buf); + if (retval) return retval; - } sum += length; @@ -1461,10 +1451,8 @@ asn1_error_code asn1_encode_subject_pk_info(asn1buf *buf, const krb5_subject_pk_ val->algorithm.parameters.length + length, &length); - if (retval) { - asn1buf_destroy(&buf); + if (retval) return retval; - } sum += length; } @@ -1661,10 +1649,8 @@ asn1_error_code asn1_encode_kdc_dh_key_info(asn1buf *buf, const krb5_kdc_dh_key_ retval = asn1_make_etag(buf, CONTEXT_SPECIFIC, 0, val->subjectPublicKey.length + 1 + length, &length); - if (retval) { - asn1buf_destroy(&buf); + if (retval) return retval; - } sum += length; } @@ -1738,10 +1724,8 @@ asn1_error_code asn1_encode_td_trusted_certifiers(asn1buf *buf, const krb5_exter { unsigned int length; retval = asn1_encode_sequence_of_external_principal_identifier(buf, val, &length); - if (retval) { - asn1buf_destroy(&buf); + if (retval) return retval; - } /* length set but ignored? sum not updated? */ } asn1_cleanup(); -- 2.26.2