From 3d6a1dab31c33bd568d49f8496ed86c75813f102 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Sat, 26 Aug 1995 01:46:44 +0000 Subject: [PATCH] krb5_encode.c (encode_krb5_padata_sequence): New function which encodes a sequence of pa_data elements krb5_decode.c (decode_krb5_padata_sequence): New function which decodes a sequence of pa_data elements. asn1_k_encode.c (asn1_encode_sequence_of_pa_data): Make it possible to encode sequence of zero pa_data elements. asn1_k_decode.c (decode_array_body): Make it possible to decode SEQUENCE OF encodinges of zero items (which is legal according to ASN.1) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6593 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/asn.1/ChangeLog | 15 +++++++++++++++ src/lib/krb5/asn.1/asn1_k_decode.c | 2 ++ src/lib/krb5/asn.1/asn1_k_encode.c | 2 +- src/lib/krb5/asn.1/krb5_decode.c | 12 ++++++++++++ src/lib/krb5/asn.1/krb5_encode.c | 14 ++++++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index 07e82b5a6..a558cf428 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,18 @@ +Fri Aug 25 21:43:42 1995 Theodore Y. Ts'o + + * krb5_encode.c (encode_krb5_padata_sequence): New function which + encodes a sequence of pa_data elements + + * krb5_decode.c (decode_krb5_padata_sequence): New function which + decodes a sequence of pa_data elements. + + * asn1_k_encode.c (asn1_encode_sequence_of_pa_data): Make it + possible to encode sequence of zero pa_data elements. + + * asn1_k_decode.c (decode_array_body): Make it possible to decode + SEQUENCE OF encodinges of zero items (which is legal + according to ASN.1) + Sat Jun 17 00:00:33 1995 Theodore Y. Ts'o (tytso@dcl) * asn1_get.c (asn1_get_tag): Added change to allow for diff --git a/src/lib/krb5/asn.1/asn1_k_decode.c b/src/lib/krb5/asn.1/asn1_k_decode.c index 159667923..da748c4e8 100644 --- a/src/lib/krb5/asn.1/asn1_k_decode.c +++ b/src/lib/krb5/asn.1/asn1_k_decode.c @@ -514,6 +514,8 @@ if(*(array) == NULL) return ENOMEM;\ get_element(elt,decoder);\ array_append(val,size,elt,type);\ }\ + if (*val == NULL)\ + *val = (type **)malloc(sizeof(type*));\ (*val)[size] = NULL;\ end_sequence_of(buf);\ }\ diff --git a/src/lib/krb5/asn.1/asn1_k_encode.c b/src/lib/krb5/asn.1/asn1_k_encode.c index 731083a99..98c4fc4c9 100644 --- a/src/lib/krb5/asn.1/asn1_k_encode.c +++ b/src/lib/krb5/asn.1/asn1_k_encode.c @@ -571,7 +571,7 @@ asn1_error_code asn1_encode_sequence_of_pa_data(buf, val, retlen) asn1_setup(); int i; - if(val == NULL || val[0] == NULL) return ASN1_MISSING_FIELD; + if (val == NULL) return ASN1_MISSING_FIELD; for(i=0; val[i] != NULL; i++); for(i--; i>=0; i--){ diff --git a/src/lib/krb5/asn.1/krb5_decode.c b/src/lib/krb5/asn.1/krb5_decode.c index fd716f4b4..7fdd8d777 100644 --- a/src/lib/krb5/asn.1/krb5_decode.c +++ b/src/lib/krb5/asn.1/krb5_decode.c @@ -603,3 +603,15 @@ krb5_error_code decode_krb5_pwd_data(code, rep) end_structure (); } cleanup(); } + +krb5_error_code decode_krb5_padata_sequence(code, rep) + const krb5_data * code; + krb5_pa_data ***rep; +{ + setup_buf_only(); + *rep = 0; + retval = asn1_decode_sequence_of_pa_data(&buf,rep); + if(retval) return (krb5_error_code)retval; + cleanup(); +} + diff --git a/src/lib/krb5/asn.1/krb5_encode.c b/src/lib/krb5/asn.1/krb5_encode.c index aa7ad61d1..8928f56b8 100644 --- a/src/lib/krb5/asn.1/krb5_encode.c +++ b/src/lib/krb5/asn.1/krb5_encode.c @@ -719,3 +719,17 @@ krb5_error_code encode_krb5_pwd_data(rep, code) krb5_makeseq(); krb5_cleanup(); } + +krb5_error_code encode_krb5_padata_sequence(rep, code) + const krb5_pa_data ** rep; + krb5_data ** code; +{ + krb5_setup(); + + retval = asn1_encode_sequence_of_pa_data(buf,rep,&length); + if(retval) return retval; + sum += length; + + krb5_cleanup(); +} + -- 2.26.2