]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add base type macro to ensure we don't get tripped up by flags
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 15 May 2016 16:03:02 +0000 (12:03 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 15 May 2016 16:03:02 +0000 (12:03 -0400)
src/include/conffile.h
src/main/command.c
src/main/conffile.c
src/main/unittest.c

index 31e1f39937d59d5f02b5329afd17fca3efcee3b5..7b5c93f73177b2e677ad1aba02cbc5ae8c5c3701 100644 (file)
@@ -240,6 +240,8 @@ typedef struct timeval _timeval_t;
 #define PW_TYPE_IS_SET                 (1 << 21)                       //!< Write whether this config item was
                                                                        //!< left as the default to is_set_offset
                                                                        //!< or is_set_ptr.
+
+#define PW_BASE_TYPE(_t)               (0xff & (_t))
 /* @} **/
 
 #define FR_INTEGER_COND_CHECK(_name, _var, _cond, _new)\
index 825e4cf693d5d3283bb07135260c799b7d3b5f17..58081cd255beda8e0a36c50dfbd51f09ba3a5166 100644 (file)
@@ -2316,7 +2316,7 @@ static int command_set_module_config(rad_listen_t *listener, int argc, char *arg
                /*
                 *      FIXME: Recurse into sub-types somehow...
                 */
-               if (variables[i].type == PW_TYPE_SUBSECTION) continue;
+               if (PW_BASE_TYPE(variables[i].type) == PW_TYPE_SUBSECTION) continue;
 
                if (strcmp(variables[i].name, argv[1]) == 0) {
                        rcode = i;
index 0e4cdbdab5f888519620e86ada37962beab3c781..313e9ee1214486c5509822d01f1fd9fd8f767fdd 100644 (file)
@@ -1435,7 +1435,7 @@ int cf_section_parse_pass2(CONF_SECTION *cs, void *base, CONF_PARSER const varia
                attribute = (type & PW_TYPE_ATTRIBUTE);
                multi = (type & PW_TYPE_MULTI);
 
-               type &= 0xff;           /* normal types are small */
+               type = PW_BASE_TYPE(type);              /* normal types are small */
 
                /*
                 *      It's a section, recurse!
@@ -1633,7 +1633,7 @@ static int cf_pair_parse_value(void *out, TALLOC_CTX *ctx, CONF_SECTION *cs, CON
 
        if (required) cant_be_empty = true;             /* May want to review this in the future... */
 
-       type &= 0xff;                                   /* normal types are small */
+       type = PW_BASE_TYPE(type);                                      /* normal types are small */
 
        /*
         *      Everything except templates must have a base type.
@@ -1917,7 +1917,7 @@ static int cf_pair_default(CONF_PAIR **out, CONF_SECTION *cs, char const *name,
        CONF_PAIR       *cp;
        char            buffer[8192];
 
-       type &= 0xff;
+       type = PW_BASE_TYPE(type);
 
        /*
         *      Defaults may need their values expanding
@@ -2098,7 +2098,7 @@ int cf_pair_parse(CONF_SECTION *cs, char const *name, unsigned int type, void *d
                 *      We don't NULL terminate.  Consumer must use
                 *      talloc_array_length().
                 */
-               } else switch (type & 0xff) {
+               } else switch (PW_BASE_TYPE(type)) {
                case PW_TYPE_BOOLEAN:
                        array = (void **)talloc_zero_array(cs, bool, count);
                        break;
@@ -2205,7 +2205,7 @@ static void cf_section_parse_init(CONF_SECTION *cs, void *base, CONF_PARSER cons
        int i;
 
        for (i = 0; variables[i].name != NULL; i++) {
-               if ((variables[i].type & 0xff) == PW_TYPE_SUBSECTION) {
+               if (PW_BASE_TYPE(variables[i].type) == PW_TYPE_SUBSECTION) {
                        CONF_SECTION *subcs;
 
                        if (!variables[i].dflt) continue;
@@ -2233,7 +2233,7 @@ static void cf_section_parse_init(CONF_SECTION *cs, void *base, CONF_PARSER cons
                        continue;
                }
 
-               if ((variables[i].type != PW_TYPE_STRING) &&
+               if ((PW_BASE_TYPE(variables[i].type) != PW_TYPE_STRING) &&
                    (variables[i].type != PW_TYPE_FILE_INPUT) &&
                    (variables[i].type != PW_TYPE_FILE_OUTPUT)) {
                        continue;
@@ -2312,7 +2312,7 @@ int cf_section_parse(CONF_SECTION *cs, void *base, CONF_PARSER const *variables)
                /*
                 *      Handle subsections specially
                 */
-               if (variables[i].type == PW_TYPE_SUBSECTION) {
+               if (PW_BASE_TYPE(variables[i].type) == PW_TYPE_SUBSECTION) {
                        CONF_SECTION *subcs;
 
                        subcs = cf_section_sub_find(cs, variables[i].name);
index 6cc3fc165936ce4494b3a32fa1947e0ad270aa6f..71395252b52f3951ea25e7ecf202aded47dd66ee 100644 (file)
@@ -495,7 +495,7 @@ static ssize_t xlat_poke(char **out, size_t outlen,
        for (i = 0; variables[i].name != NULL; i++) {
                int ret;
 
-               if (variables[i].type == PW_TYPE_SUBSECTION) continue;
+               if (PW_BASE_TYPE(variables[i].type) == PW_TYPE_SUBSECTION) continue;
                /* else it's a CONF_PAIR */
 
                /*