From: Alan T. DeKok Date: Fri, 29 Dec 2017 14:52:50 +0000 (-0500) Subject: more sanity checks X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=afbf6dc7f99c23a2903a265d4aac3ba16d3ea273;p=thirdparty%2Ffreeradius-server.git more sanity checks - that we're listening for request packets. - that there is a 'recv foo' section if we're listening for 'foo' --- diff --git a/src/modules/proto_radius/proto_radius.c b/src/modules/proto_radius/proto_radius.c index 5fee3763165..71d74561f04 100644 --- a/src/modules/proto_radius/proto_radius.c +++ b/src/modules/proto_radius/proto_radius.c @@ -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;