]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
process/bfd: replace assert with runtime validation in resume_recv_bfd
authorAlexander Bainbridge-Sedivy <alex.bainbridge@inkbridge.io>
Wed, 27 May 2026 15:53:44 +0000 (11:53 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 28 May 2026 19:53:44 +0000 (15:53 -0400)
src/process/bfd/base.c

index ef2c3031d6628b528cf8f24484a2dd90a2001beb..8e29d1ad5820e138073fda4e0387d567fb3509c9 100644 (file)
@@ -134,16 +134,24 @@ RESUME_FLAG(recv_bfd, UNUSED,)
                 */
                vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_packet_type);
                if (vp) {
+                       if (!PROCESS_PACKET_CODE_VALID(vp->vp_uint32)) {
+                               REDEBUG("Invalid BFD packet type %u", vp->vp_uint32);
+                               RETURN_UNLANG_FAIL;
+                       }
                        state = vp->vp_uint32;
                } else {
                        vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_bfd_packet);
                        if (vp) vp = fr_pair_find_by_da_nested(&vp->vp_group, NULL, attr_bfd_state);
-                       if (vp) state = vp->vp_uint8;
+                       if (vp) {
+                               if (!PROCESS_PACKET_CODE_VALID(vp->vp_uint8)) {
+                                       REDEBUG("Invalid BFD state %u", vp->vp_uint8);
+                                       RETURN_UNLANG_FAIL;
+                               }
+                               state = vp->vp_uint8;
+                       }
                }
        }
 
-       fr_assert(PROCESS_PACKET_CODE_VALID(state));
-
        request->reply->code = state;
 
        request->reply->timestamp = fr_time();
@@ -243,7 +251,6 @@ static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const
         *      If there's no packet, we must be calling the "send" routine
         */
        if (wrapper->type == BFD_WRAPPER_SEND_PACKET) {
-               fr_assert(wrapper->type == BFD_WRAPPER_SEND_PACKET);
 
                UPDATE_STATE(reply);