aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Nikolaev <anikolaev@netgate.com>2024-02-22 09:21:45 +0000
committerMatthew Smith <mgsmith@netgate.com>2024-04-15 14:41:21 +0000
commit4ebe5eef8a696a349105d6bdf21c8c11db938a1d (patch)
treee23606793725d2700f09f1ab30570af3d79b40c5
parentd7f0daeccef4fd062e143e0030cf973e2cdf9ef9 (diff)
linux-cp: fix seg fault in get_v2 methods
vl_api_lcp_itf_pair_get_v2_t_handler method was not be able to handle invalid sw_if_index, it caused a seg fault. With this fix, the method checks for an invalid sw_if_index and sends error back to caller. Type: fix Change-Id: I4e89b0cab34f9109c4ce2689021ecfc2786055ab Signed-off-by: Anton Nikolaev <anikolaev@netgate.com>
-rw-r--r--src/plugins/linux-cp/lcp_api.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/plugins/linux-cp/lcp_api.c b/src/plugins/linux-cp/lcp_api.c
index 991516a3ecd..74421230e9d 100644
--- a/src/plugins/linux-cp/lcp_api.c
+++ b/src/plugins/linux-cp/lcp_api.c
@@ -214,9 +214,16 @@ vl_api_lcp_itf_pair_get_v2_t_handler (vl_api_lcp_itf_pair_get_v2_t *mp)
else
{
VALIDATE_SW_IF_INDEX_END (mp);
+
+ u32 pair_index = lcp_itf_pair_find_by_phy (mp->sw_if_index);
+ if (pair_index == INDEX_INVALID)
+ {
+ rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
+ goto bad_sw_if_index;
+ }
send_lcp_itf_pair_details (
- lcp_itf_pair_find_by_phy (mp->sw_if_index),
- vl_api_client_index_to_registration (mp->client_index), mp->context);
+ pair_index, vl_api_client_index_to_registration (mp->client_index),
+ mp->context);
BAD_SW_IF_INDEX_LABEL;
REPLY_MACRO2_END (VL_API_LCP_ITF_PAIR_GET_V2_REPLY,