From: Tom Yu Date: Fri, 4 Dec 1998 00:42:41 +0000 (+0000) Subject: * asn1_k_decode.c (asn1_decode_krb5_flags): Modify to deal with X-Git-Tag: krb5-1.1-beta1~464 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=462e5b1415c2917596e1730ee2cfc23c7bb18556;p=krb5.git * asn1_k_decode.c (asn1_decode_krb5_flags): Modify to deal with BIT STRING values that are not exactly 32 bits. Throw away bits beyond number 31 in a bit string for now. Deal with masking out unused bits. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11055 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index ca3f679f5..a3d98ad5f 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,10 @@ +Thu Dec 3 19:41:06 1998 Tom Yu + + * asn1_k_decode.c (asn1_decode_krb5_flags): Modify to deal with + BIT STRING values that are not exactly 32 bits. Throw away bits + beyond number 31 in a bit string for now. Deal with masking out + unused bits. + 1998-10-27 Marc Horowitz * asn1buf.c (asn1buf_sync): interoperation testing against heimdal diff --git a/src/lib/krb5/asn.1/asn1_k_decode.c b/src/lib/krb5/asn.1/asn1_k_decode.c index 475bc0677..226b0443d 100644 --- a/src/lib/krb5/asn.1/asn1_k_decode.c +++ b/src/lib/krb5/asn.1/asn1_k_decode.c @@ -272,7 +272,7 @@ asn1_error_code asn1_decode_krb5_flags(buf, val) krb5_flags * val; { setup(); - asn1_octet o; + asn1_octet unused, o; int i; krb5_flags f=0; unused_var(taglen); @@ -281,16 +281,24 @@ asn1_error_code asn1_decode_krb5_flags(buf, val) if(retval) return retval; if(class != UNIVERSAL || construction != PRIMITIVE || tagnum != ASN1_BITSTRING) return ASN1_BAD_ID; - if(length != 5) return ASN1_BAD_LENGTH; - retval = asn1buf_remove_octet(buf,&o); /* # of padding bits */ - if(retval) return retval; /* should be 0 */ - if(o != 0) return ASN1_BAD_FORMAT; + retval = asn1buf_remove_octet(buf,&unused); /* # of padding bits */ + if(retval) return retval; + + /* Number of unused bits must be between 0 and 7. */ + if (unused > 7) return ASN1_BAD_FORMAT; + length--; - for(i=0; i<4; i++){ + for(i = 0; i < length; i++) { retval = asn1buf_remove_octet(buf,&o); if(retval) return retval; - f = (f<<8) | ((krb5_flags)o&0xFF); + /* ignore bits past number 31 */ + if (i < 4) + f = (f<<8) | ((krb5_flags)o&0xFF); + } + if (length <= 4) { + /* Mask out unused bits, but only if necessary. */ + f &= ~0 << unused; } *val = f; return 0;