From 35e5db4310cce8362834f56d22290e572dc1851e Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Thu, 7 Nov 2002 20:09:02 +0000 Subject: [PATCH] * asn1_k_encode.c (asn1_encode_sam_challenge_2): Test for error returned from asn1buf_insert_oxtetstring and cleanup strctures properly. * asn1_k_decode.c (asn1_decode_sam_challenge_2_body): Change sequence_of/end_sequence_of to use sequence_of_no_tagvars/end_sequence_of_no_tagravs to avoid shadowing variables. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14975 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/asn.1/ChangeLog | 11 +++++++++++ src/lib/krb5/asn.1/asn1_k_decode.c | 4 ++-- src/lib/krb5/asn.1/asn1_k_encode.c | 15 +++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index a2fe87030..81a841966 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,14 @@ +2002-11-07 Ezra Peisach + + * asn1_k_encode.c (asn1_encode_sam_challenge_2): Test for error + returned from asn1buf_insert_oxtetstring and cleanup strctures + properly. + + * asn1_k_decode.c (asn1_decode_sam_challenge_2_body): Change + sequence_of/end_sequence_of to use + sequence_of_no_tagvars/end_sequence_of_no_tagravs to avoid + shadowing variables. + 2002-11-07 Ezra Peisach * asn1_k_encode.c (add_optstring): Add optional string only if diff --git a/src/lib/krb5/asn.1/asn1_k_decode.c b/src/lib/krb5/asn.1/asn1_k_decode.c index f075db094..0a827b160 100644 --- a/src/lib/krb5/asn.1/asn1_k_decode.c +++ b/src/lib/krb5/asn.1/asn1_k_decode.c @@ -821,8 +821,8 @@ asn1_error_code asn1_decode_sam_challenge_2(asn1buf *buf, krb5_sam_challenge_2 * if (asn1class != CONTEXT_SPECIFIC || construction != CONSTRUCTED) return ASN1_BAD_ID; save = subbuf.next; - { sequence_of(&subbuf); - end_sequence_of(&subbuf); + { sequence_of_no_tagvars(&subbuf); + end_sequence_of_no_tagvars(&subbuf); } end = subbuf.next; if ((val->sam_challenge_2_body.data = (char *) malloc(end - save)) == NULL) diff --git a/src/lib/krb5/asn.1/asn1_k_encode.c b/src/lib/krb5/asn.1/asn1_k_encode.c index ff15d7067..9226f7ca2 100644 --- a/src/lib/krb5/asn.1/asn1_k_encode.c +++ b/src/lib/krb5/asn.1/asn1_k_encode.c @@ -807,14 +807,21 @@ asn1_error_code asn1_encode_sam_challenge_2(asn1buf *buf, const krb5_sam_challen return ASN1_MISSING_FIELD; asn1_addfield((const krb5_checksum **) val->sam_cksum, 1, asn1_encode_sequence_of_checksum); - asn1buf_insert_octetstring(buf, val->sam_challenge_2_body.length, - (unsigned char *)val->sam_challenge_2_body.data); + retval = asn1buf_insert_octetstring(buf, val->sam_challenge_2_body.length, + (unsigned char *)val->sam_challenge_2_body.data); + if(retval){ + asn1buf_destroy(&buf); + return retval; + } sum += val->sam_challenge_2_body.length; retval = asn1_make_etag(buf, CONTEXT_SPECIFIC, 0, val->sam_challenge_2_body.length, &length); - if(retval) return retval; + if(retval) { + asn1buf_destroy(&buf); + return retval; + } sum += length; - + asn1_makeseq(); asn1_cleanup(); } -- 2.26.2