+Thu Dec 3 19:41:06 1998 Tom Yu <tlyu@mit.edu>
+
+ * 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 <marc@mit.edu>
* asn1buf.c (asn1buf_sync): interoperation testing against heimdal
krb5_flags * val;
{
setup();
- asn1_octet o;
+ asn1_octet unused, o;
int i;
krb5_flags f=0;
unused_var(taglen);
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;