]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
minor cleanups
authorAlan T. DeKok <aland@freeradius.org>
Sun, 16 Feb 2025 20:27:37 +0000 (15:27 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 16 Feb 2025 20:27:37 +0000 (15:27 -0500)
src/protocols/der/decode.c
src/protocols/der/der.h

index 0d54e454b5e9cac8f87bcb6a1577fd6d00c070ef..20211b2c8e8fd6c5c741b546cc47319038b6d96b 100644 (file)
@@ -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
         */
index 52e57b3c5441050f3ac2abd51f3af0887b37c7a9..9a833e1518c9db5d3672cfecc48da5d97ee6d6c3 100644 (file)
@@ -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.