asn1buf_skiptail().
* asn1buf.c (asn1buf_sync): Fix to deal with
constructed-indefinite encodings with trailing fields. As a
result, this requires that the most recently read tag number be
passed in.
(asn1buf_skiptail): New helper function to skip trailing fields in
a constructed-indefinite encoding.
* krb5_decode.c (end_structure): Hack to deal with changed
asn1buf_sync().
* asn1_k_decode.c (end_structure, end_sequence_of): Hack to deal
with changed asn1buf_sync().
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11541
dc483132-0cff-0310-8789-
dd5450dbe970
+1999-07-03 Tom Yu <tlyu@mit.edu>
+
+ * asn1buf.h: New prototpyes for asn1buf_sync() and
+ asn1buf_skiptail().
+
+ * asn1buf.c (asn1buf_sync): Fix to deal with
+ constructed-indefinite encodings with trailing fields. As a
+ result, this requires that the most recently read tag number be
+ passed in.
+ (asn1buf_skiptail): New helper function to skip trailing fields in
+ a constructed-indefinite encoding.
+
+ * krb5_decode.c (end_structure): Hack to deal with changed
+ asn1buf_sync().
+
+ * asn1_k_decode.c (end_structure, end_sequence_of): Hack to deal
+ with changed asn1buf_sync().
+
1999-06-30 Tom Yu <tlyu@mit.edu>
* asn1buf.c (asn1buf_sync): Interim fix for DCE compat problem
#define get_field_body(var,decoder)\
retval = decoder(&subbuf,&(var));\
if(retval) return retval;\
-if(!taglen) next_tag();\
+if(!taglen) { next_tag(); }\
next_tag()
#define get_field(var,tagexpect,decoder)\
#define get_lenfield_body(len,var,decoder)\
retval = decoder(&subbuf,&(len),&(var));\
if(retval) return retval;\
-if(!taglen) next_tag();\
+if(!taglen) { next_tag(); }\
next_tag()
#define get_lenfield(len,var,tagexpect,decoder)\
next_tag()
#define end_structure()\
-asn1buf_sync(buf,&subbuf)
+retval = asn1buf_sync(buf,&subbuf,tagnum);\
+if(retval) return retval
#define sequence_of(buf)\
int size=0;\
if(retval) return retval
#define end_sequence_of(buf)\
-asn1buf_sync(buf,&seqbuf)
+retval = asn1buf_sync(buf,&seqbuf,ASN1_TAGNUM_CEILING);\
+if(retval) return retval
#define cleanup()\
return 0
#include "asn1buf.h"
#undef ASN1BUF_OMIT_INLINE_FUNCS
#include <stdio.h>
+#include "asn1_get.h"
asn1_error_code asn1buf_create(buf)
asn1buf ** buf;
return 0;
}
-void asn1buf_sync(buf, subbuf)
+asn1_error_code asn1buf_sync(buf, subbuf, lasttag)
asn1buf * buf;
asn1buf * subbuf;
+ asn1_tagnum lasttag;
{
+ asn1_error_code retval;
+
if (subbuf->bound != buf->bound) {
buf->next = subbuf->bound + 1;
} else {
/*
- * indefinite length; this will suck
- * XXX - need to skip fields somehow
+ * indefinite length:
+ *
+ * Note that asn1_get_tag() returns ASN1_TAGNUM_CEILING
+ * for an EOC encoding.
*/
+ if (lasttag != ASN1_TAGNUM_CEILING) {
+ retval = asn1buf_skiptail(subbuf);
+ if (retval) return retval;
+ }
buf->next = subbuf->next;
}
+ return 0;
+}
+
+asn1_error_code asn1buf_skiptail(buf)
+ asn1buf *buf;
+{
+ asn1_error_code retval;
+ asn1_class class;
+ asn1_construction construction;
+ asn1_tagnum tagnum;
+ int taglen;
+ int nestlevel;
+
+ nestlevel = 1;
+ while (nestlevel > 0) {
+ retval = asn1_get_tag(buf, &class, &construction, &tagnum, &taglen);
+ if (retval) return retval;
+ if (construction == CONSTRUCTED && taglen == 0)
+ nestlevel++;
+ if (tagnum == ASN1_TAGNUM_CEILING)
+ nestlevel--;
+ }
+ return 0;
}
asn1_error_code asn1buf_destroy(buf)
that case, ASN1_OVERRUN is returned) *subbuf's current
position starts at the beginning of *subbuf. */
-void asn1buf_sync
- PROTOTYPE((asn1buf *buf, asn1buf *subbuf));
+asn1_error_code asn1buf_sync
+ PROTOTYPE((asn1buf *buf, asn1buf *subbuf, asn1_tagnum lasttag));
/* requires *subbuf is a sub-buffer of *buf, as created by asn1buf_imbed.
+ lasttag is a pointer to the last tagnumber read.
effects Synchronizes *buf's current position to match that of *subbuf. */
+asn1_error_code asn1buf_skiptail
+ PROTOTYPE((asn1buf *buf));
+/* requires *buf is a subbuffer used in a decoding of a
+ constructed indefinite sequence.
+ effects skips trailing fields. */
+
asn1_error_code asn1buf_destroy
PROTOTYPE((asn1buf **buf));
/* effects Deallocates **buf, sets *buf to NULL. */
next_tag()
#define end_structure()\
-asn1buf_sync(&buf,&subbuf)
+retval = asn1buf_sync(&buf,&subbuf,tagnum);\
+if (retval) clean_return(retval)
/* process fields *******************************************/
/* normal fields ************************/