Skip to content

Commit af4a8b2

Browse files
Alexander Bainbridge-Sedivyalandekok
authored andcommitted
process/bfd: replace assert with runtime validation in resume_recv_bfd
1 parent 58ffcc6 commit af4a8b2

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/process/bfd/base.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,24 @@ RESUME_FLAG(recv_bfd, UNUSED,)
134134
*/
135135
vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_packet_type);
136136
if (vp) {
137+
if (!PROCESS_PACKET_CODE_VALID(vp->vp_uint32)) {
138+
REDEBUG("Invalid BFD packet type %u", vp->vp_uint32);
139+
RETURN_UNLANG_FAIL;
140+
}
137141
state = vp->vp_uint32;
138142
} else {
139143
vp = fr_pair_find_by_da(&request->reply_pairs, NULL, attr_bfd_packet);
140144
if (vp) vp = fr_pair_find_by_da_nested(&vp->vp_group, NULL, attr_bfd_state);
141-
if (vp) state = vp->vp_uint8;
145+
if (vp) {
146+
if (!PROCESS_PACKET_CODE_VALID(vp->vp_uint8)) {
147+
REDEBUG("Invalid BFD state %u", vp->vp_uint8);
148+
RETURN_UNLANG_FAIL;
149+
}
150+
state = vp->vp_uint8;
151+
}
142152
}
143153
}
144154

145-
fr_assert(PROCESS_PACKET_CODE_VALID(state));
146-
147155
request->reply->code = state;
148156

149157
request->reply->timestamp = fr_time();
@@ -243,7 +251,6 @@ static unlang_action_t mod_process(unlang_result_t *p_result, module_ctx_t const
243251
* If there's no packet, we must be calling the "send" routine
244252
*/
245253
if (wrapper->type == BFD_WRAPPER_SEND_PACKET) {
246-
fr_assert(wrapper->type == BFD_WRAPPER_SEND_PACKET);
247254

248255
UPDATE_STATE(reply);
249256

0 commit comments

Comments
 (0)