]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
more sanity checks
authorAlan T. DeKok <aland@freeradius.org>
Fri, 29 Dec 2017 14:52:50 +0000 (09:52 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 29 Dec 2017 14:52:50 +0000 (09:52 -0500)
- that we're listening for request packets.
- that there is a 'recv foo' section if we're listening for 'foo'

src/modules/proto_radius/proto_radius.c

index 5fee3763165e9503db5f4a8ea3945c49e30d1ebb..71d74561f04a02bcb4276dbee16733763c7fb2d2 100644 (file)
@@ -120,12 +120,27 @@ static int type_parse(TALLOC_CTX *ctx, void *out, CONF_ITEM *ci, UNUSED CONF_PAR
        cf_data_add(ci, type_enum, NULL, false);
 
        code = type_enum->value->vb_uint32;
-       if (code >= FR_CODE_MAX) {
+       if (code > FR_CODE_MAX) {
        invalid_type:
                cf_log_err(ci, "Unsupported 'type = %s'", type_str);
                return -1;
        }
 
+       if (!fr_request_packets[code]) {
+               cf_log_err(ci, "Cannot listen for 'type = %s'.  The packet MUST be a request.", type_str);
+               return -1;
+       }
+
+       /*
+        *      Setting 'type = foo' means you MUST have at least a
+        *      'recv foo' section.
+        */
+       if (!cf_section_find(server, "recv", type_enum->alias)) {
+               cf_log_err(ci, "Failed finding 'recv %s {...} section of virtual server %s",
+                          type_enum->alias, cf_section_name2(server));
+               return -1;
+       }
+
        name = type_lib_table[code];
        if (!name) goto invalid_type;