diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/ipxe/asn1.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/include/ipxe/asn1.h b/src/include/ipxe/asn1.h index 5fbd58281..2e635b48a 100644 --- a/src/include/ipxe/asn1.h +++ b/src/include/ipxe/asn1.h @@ -315,14 +315,26 @@ struct asn1_bit_string { } __attribute__ (( packed )); /** + * Invalidate ASN.1 object cursor + * + * @v cursor ASN.1 object cursor + */ +static inline __attribute__ (( always_inline )) void +asn1_invalidate_cursor ( struct asn1_cursor *cursor ) { + cursor->len = 0; +} + +/** * Extract ASN.1 type * * @v cursor ASN.1 object cursor - * @ret type Type + * @ret type Type, or ASN1_END if cursor is invalid */ static inline __attribute__ (( always_inline )) unsigned int asn1_type ( const struct asn1_cursor *cursor ) { - return ( *( ( const uint8_t * ) cursor->data ) ); + const uint8_t *type = cursor->data; + + return ( ( cursor->len >= sizeof ( *type ) ) ? *type : ASN1_END ); } extern void asn1_invalidate_cursor ( struct asn1_cursor *cursor ); |
