From: Alan T. DeKok Date: Sun, 16 Feb 2025 20:27:37 +0000 (-0500) Subject: minor cleanups X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ca1fd358b56eeb235ba08597816f38d60c1be49;p=thirdparty%2Ffreeradius-server.git minor cleanups --- diff --git a/src/protocols/der/decode.c b/src/protocols/der/decode.c index 0d54e454b5e..20211b2c8e8 100644 --- a/src/protocols/der/decode.c +++ b/src/protocols/der/decode.c @@ -1591,23 +1591,21 @@ static ssize_t fr_der_decode_hdr(fr_dict_attr_t const *parent, fr_dbuff_t *in, u * The data type will need to be resolved using the dictionary and the tag value */ - if (parent == NULL) { + if (!parent) { fr_strerror_const("No parent attribute to resolve tag"); return -1; } - if (tag_class == fr_der_flag_class(parent)) { - if (*tag == fr_der_flag_tagnum(parent)) { - *tag = fr_der_flag_der_type(parent); - } else { - goto bad_tag; - } - } else { + if (tag_class != fr_der_flag_class(parent)) { bad_tag: fr_strerror_printf("Invalid tag %" PRIu64 " for attribute %s. Expected %" PRIu32, *tag, parent->name, fr_der_flag_tagnum(parent)); return -1; } + + if (*tag != fr_der_flag_tagnum(parent)) goto bad_tag; + + *tag = fr_der_flag_der_type(parent); } if ((*tag > NUM_ELEMENTS(tag_funcs)) || (*tag == FR_DER_TAG_INVALID)) { @@ -1616,6 +1614,7 @@ static ssize_t fr_der_decode_hdr(fr_dict_attr_t const *parent, fr_dbuff_t *in, u } func = &tag_funcs[*tag]; + /* * Check if the tag is an OID. OID tags will be handled differently */ diff --git a/src/protocols/der/der.h b/src/protocols/der/der.h index 52e57b3c544..9a833e1518c 100644 --- a/src/protocols/der/der.h +++ b/src/protocols/der/der.h @@ -56,8 +56,6 @@ typedef enum { #define DER_TAG_CONSTRUCTED_MASK 0x20 //!< Mask to check if the tag is constructed. #define DER_TAG_NUM_MASK 0x1f //!< Mask to extract the tag number from the tag. -#define DER_MAX_TAG_NUM 0xfe * 8 //!< Maximum tag number that can be encoded in a single byte. - #define DER_TAG_CONTINUATION 0x1f //!< Mask to check if the tag is a continuation. #define DER_LEN_MULTI_BYTE 0x80 //!< Mask to check if the length is multi-byte.