@@ -2124,6 +2124,42 @@ static int test_static_routes(void) {
21242124 & inexact_matches ,
21252125 & route_ref ));
21262126
2127+ /* regression test: a route that is both PENALTYBOXED and GREENLISTED must
2128+ * reject (penaltybox takes precedence), not accept and reject together.
2129+ */
2130+ {
2131+ wolfsentry_route_flags_t flags_before , flags_after ;
2132+ WOLFSENTRY_EXIT_ON_FAILURE (wolfsentry_route_update_flags (
2133+ WOLFSENTRY_CONTEXT_ARGS_OUT ,
2134+ route_ref ,
2135+ WOLFSENTRY_ROUTE_FLAG_PENALTYBOXED ,
2136+ WOLFSENTRY_ROUTE_FLAG_NONE ,
2137+ & flags_before ,
2138+ & flags_after ,
2139+ & action_results ));
2140+ WOLFSENTRY_EXIT_ON_FALSE (WOLFSENTRY_CHECK_BITS (flags_after , WOLFSENTRY_ROUTE_FLAG_PENALTYBOXED ));
2141+ WOLFSENTRY_EXIT_ON_FALSE (WOLFSENTRY_CHECK_BITS (flags_after , WOLFSENTRY_ROUTE_FLAG_GREENLISTED ));
2142+
2143+ WOLFSENTRY_CLEAR_ALL_BITS (action_results );
2144+ WOLFSENTRY_EXIT_ON_FAILURE (wolfsentry_route_event_dispatch_with_inited_result (
2145+ WOLFSENTRY_CONTEXT_ARGS_OUT ,
2146+ & remote .sa , & local .sa , flags ,
2147+ NULL /* event_label */ , 0 /* event_label_len */ ,
2148+ NULL /* caller_arg */ ,
2149+ & route_id , & inexact_matches , & action_results ));
2150+ WOLFSENTRY_EXIT_ON_FALSE (WOLFSENTRY_CHECK_BITS (action_results , WOLFSENTRY_ACTION_RES_REJECT ));
2151+ WOLFSENTRY_EXIT_ON_TRUE (WOLFSENTRY_CHECK_BITS (action_results , WOLFSENTRY_ACTION_RES_ACCEPT ));
2152+
2153+ WOLFSENTRY_EXIT_ON_FAILURE (wolfsentry_route_update_flags (
2154+ WOLFSENTRY_CONTEXT_ARGS_OUT ,
2155+ route_ref ,
2156+ WOLFSENTRY_ROUTE_FLAG_NONE ,
2157+ WOLFSENTRY_ROUTE_FLAG_PENALTYBOXED ,
2158+ & flags_before ,
2159+ & flags_after ,
2160+ & action_results ));
2161+ }
2162+
21272163
21282164 {
21292165 int old_derogatory_count ;
0 commit comments