]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
RLM_MODULE_NOT_SET=0 so that zeroed memory is invalid.
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 15 Jul 2025 05:14:00 +0000 (23:14 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 15 Jul 2025 05:14:00 +0000 (23:14 -0600)
src/lib/server/rcode.h
src/lib/unlang/module.c

index a304d50e31169a20585afcddeae525044bef6f3d..b0b0d6b34a9ce9df8708903e33384158d0437ac7 100644 (file)
@@ -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;
index 25854e53fcf904894a3ec24b78d946c0c76249e5..0c3985c13ba3ba42c9420a9a66466218d64e94d3 100644 (file)
@@ -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, "<invalid>"));