aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-04-16 07:28:25 -0400
committerFlorin Coras <florin.coras@gmail.com>2019-04-16 14:53:20 +0000
commit958170a45f35ad1f08c1af48990a6b0e63d6c1ee (patch)
tree8d191840a46fb8c0e8bc3988c99bdc7fe69b1ac8
parent672d5fc6d36ebc3a3815c4658a8ef3bf256ef044 (diff)
VPP-1576: nsim-plugin coverity issues
Change-Id: I832e780b00955e01871874544f3d0afc553b75f7 Signed-off-by: Dave Barach <dave@barachs.net>
-rw-r--r--src/plugins/nsim/nsim.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/plugins/nsim/nsim.c b/src/plugins/nsim/nsim.c
index 4120585c282..65344ed0113 100644
--- a/src/plugins/nsim/nsim.c
+++ b/src/plugins/nsim/nsim.c
@@ -348,11 +348,26 @@ static void vl_api_nsim_cross_connect_enable_disable_t_handler
vl_api_nsim_cross_connect_enable_disable_reply_t *rmp;
nsim_main_t *nsm = &nsim_main;
int rv;
+ u32 sw_if_index0, sw_if_index1;
- rv = nsim_cross_connect_enable_disable (nsm, ntohl (mp->sw_if_index0),
- ntohl (mp->sw_if_index1),
+ sw_if_index0 = clib_net_to_host_u32 (mp->sw_if_index0);
+ sw_if_index1 = clib_net_to_host_u32 (mp->sw_if_index1);
+
+ if (!vnet_sw_if_index_is_api_valid (sw_if_index0))
+ {
+ rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
+ goto bad_sw_if_index;
+ }
+ if (!vnet_sw_if_index_is_api_valid (sw_if_index1))
+ {
+ rv = VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
+ goto bad_sw_if_index;
+ }
+
+ rv = nsim_cross_connect_enable_disable (nsm, sw_if_index0, sw_if_index1,
(int) (mp->enable_disable));
+ BAD_SW_IF_INDEX_LABEL;
REPLY_MACRO (VL_API_NSIM_CROSS_CONNECT_ENABLE_DISABLE_REPLY);
}
@@ -363,10 +378,12 @@ static void vl_api_nsim_output_feature_enable_disable_t_handler
vl_api_nsim_output_feature_enable_disable_reply_t *rmp;
nsim_main_t *nsm = &nsim_main;
int rv;
+ VALIDATE_SW_IF_INDEX (mp);
rv = nsim_output_feature_enable_disable (nsm, ntohl (mp->sw_if_index),
(int) (mp->enable_disable));
+ BAD_SW_IF_INDEX_LABEL;
REPLY_MACRO (VL_API_NSIM_OUTPUT_FEATURE_ENABLE_DISABLE_REPLY);
}