@@ -15,11 +15,10 @@ #include "config.h" #import "OFData+ASN1DERParsing.h" #import "OFASN1BitString.h" -#import "OFASN1Boolean.h" #import "OFASN1Enumerated.h" #import "OFASN1IA5String.h" #import "OFASN1Integer.h" #import "OFASN1NumericString.h" #import "OFASN1ObjectIdentifier.h" @@ -27,10 +26,11 @@ #import "OFASN1PrintableString.h" #import "OFASN1UTF8String.h" #import "OFASN1Value.h" #import "OFArray.h" #import "OFNull.h" +#import "OFNumber.h" #import "OFSet.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" @@ -157,13 +157,26 @@ contents = [self subdataWithRange: OFMakeRange(bytesConsumed, contentsLength)]; bytesConsumed += contentsLength; switch (tag & ~tagConstructedMask) { - case OFASN1TagNumberBoolean: - valueClass = [OFASN1Boolean class]; - break; + case OFASN1TagNumberBoolean:; + unsigned char boolValue; + + if (tag & tagConstructedMask) + @throw [OFInvalidFormatException exception]; + + if (contents.count != 1) + @throw [OFInvalidFormatException exception]; + + boolValue = *(unsigned char *)[contents itemAtIndex: 0]; + + if (boolValue != 0 && boolValue != 0xFF) + @throw [OFInvalidFormatException exception]; + + *object = [OFNumber numberWithBool: boolValue]; + return bytesConsumed; case OFASN1TagNumberInteger: valueClass = [OFASN1Integer class]; break; case OFASN1TagNumberBitString: valueClass = [OFASN1BitString class];