From: Arran Cudbard-Bell Date: Tue, 15 Jul 2025 05:14:00 +0000 (-0600) Subject: RLM_MODULE_NOT_SET=0 so that zeroed memory is invalid. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df3aa58d1df19207d175ae4f6c8784411b9ce3eb;p=thirdparty%2Ffreeradius-server.git RLM_MODULE_NOT_SET=0 so that zeroed memory is invalid. --- diff --git a/src/lib/server/rcode.h b/src/lib/server/rcode.h index a304d50e31..b0b0d6b34a 100644 --- a/src/lib/server/rcode.h +++ b/src/lib/server/rcode.h @@ -38,7 +38,9 @@ extern "C" { * RLM_MODULE_NUMCODES, which is used to check for validity). */ typedef enum { - RLM_MODULE_REJECT = 0, //!< Immediately reject the request. + RLM_MODULE_NOT_SET = 0, //!< Error resolving rcode (should not be + //!< returned by modules). + RLM_MODULE_REJECT, //!< Immediately reject the request. RLM_MODULE_FAIL, //!< Module failed, don't reply. RLM_MODULE_OK, //!< The module is OK, continue. RLM_MODULE_HANDLED, //!< The module handled the request, so stop. @@ -49,21 +51,20 @@ typedef enum { RLM_MODULE_UPDATED, //!< OK (pairs modified). RLM_MODULE_TIMEOUT, //!< Module (or section) timed out. RLM_MODULE_NUMCODES, //!< How many valid return codes there are. - RLM_MODULE_NOT_SET, //!< Error resolving rcode (should not be - //!< returned by modules). } rlm_rcode_t; -#define RETURN_UNLANG_REJECT do { p_result->rcode = RLM_MODULE_REJECT; return UNLANG_ACTION_CALCULATE_RESULT; } while (0) -#define RETURN_UNLANG_FAIL do { p_result->rcode = RLM_MODULE_FAIL; return UNLANG_ACTION_FAIL; } while (0) -#define RETURN_UNLANG_OK do { p_result->rcode = RLM_MODULE_OK; return UNLANG_ACTION_CALCULATE_RESULT; } while (0) -#define RETURN_UNLANG_HANDLED do { p_result->rcode = RLM_MODULE_HANDLED; return UNLANG_ACTION_CALCULATE_RESULT; } while (0) -#define RETURN_UNLANG_INVALID do { p_result->rcode = RLM_MODULE_INVALID; return UNLANG_ACTION_CALCULATE_RESULT; } while (0) -#define RETURN_UNLANG_DISALLOW do { p_result->rcode = RLM_MODULE_DISALLOW; return UNLANG_ACTION_CALCULATE_RESULT; } while (0) -#define RETURN_UNLANG_NOTFOUND do { p_result->rcode = RLM_MODULE_NOTFOUND; return UNLANG_ACTION_CALCULATE_RESULT; } while (0) -#define RETURN_UNLANG_NOOP do { p_result->rcode = RLM_MODULE_NOOP; return UNLANG_ACTION_CALCULATE_RESULT; } while (0) -#define RETURN_UNLANG_UPDATED do { p_result->rcode = RLM_MODULE_UPDATED; return UNLANG_ACTION_CALCULATE_RESULT; } while (0) -#define RETURN_UNLANG_TIMEOUT do { p_result->rcode= RLM_MODULE_TIMEOUT; return UNLANG_ACTION_CALCULATE_RESULT; } while (0) + #define RETURN_UNLANG_RCODE(_rcode) do { p_result->rcode = (_rcode); return UNLANG_ACTION_CALCULATE_RESULT; } while (0) +#define RETURN_UNLANG_REJECT RETURN_UNLANG_RCODE(RLM_MODULE_REJECT) +#define RETURN_UNLANG_FAIL RETURN_UNLANG_RCODE(RLM_MODULE_FAIL) +#define RETURN_UNLANG_OK RETURN_UNLANG_RCODE(RLM_MODULE_OK) +#define RETURN_UNLANG_HANDLED RETURN_UNLANG_RCODE(RLM_MODULE_HANDLED) +#define RETURN_UNLANG_INVALID RETURN_UNLANG_RCODE(RLM_MODULE_INVALID) +#define RETURN_UNLANG_DISALLOW RETURN_UNLANG_RCODE(RLM_MODULE_DISALLOW) +#define RETURN_UNLANG_NOTFOUND RETURN_UNLANG_RCODE(RLM_MODULE_NOTFOUND) +#define RETURN_UNLANG_NOOP RETURN_UNLANG_RCODE(RLM_MODULE_NOOP) +#define RETURN_UNLANG_UPDATED RETURN_UNLANG_RCODE(RLM_MODULE_UPDATED) +#define RETURN_UNLANG_TIMEOUT RETURN_UNLANG_RCODE(RLM_MODULE_TIMEOUT) extern fr_table_num_sorted_t const rcode_table[]; extern size_t rcode_table_len; diff --git a/src/lib/unlang/module.c b/src/lib/unlang/module.c index 25854e53fc..0c3985c13b 100644 --- a/src/lib/unlang/module.c +++ b/src/lib/unlang/module.c @@ -566,8 +566,8 @@ static unlang_action_t unlang_module_done(unlang_result_t *p_result, request_t * fr_assert(state->unlang_indent == request->log.indent.unlang); #endif - fr_assert(p_result->rcode >= RLM_MODULE_REJECT); - fr_assert(p_result->rcode < RLM_MODULE_NOT_SET); + fr_assert(p_result->rcode >= RLM_MODULE_NOT_SET); + fr_assert(p_result->rcode < RLM_MODULE_NUMCODES); RDEBUG("%s (%s)", frame->instruction->name ? frame->instruction->name : "", fr_table_str_by_value(mod_rcode_table, p_result->rcode, ""));