summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-03-01 19:26:31 -0800
committerDave Barach <openvpp@barachs.net>2019-03-02 23:40:15 +0000
commit92311f63de1da5934403a08be57b6286e6cddb67 (patch)
treed5cd87820be757526acea9fadaa6c317c3ca6cc7 /src/vnet
parent31c9955a4e83578422b3328ef0d7b2b248536644 (diff)
session: fix unlisten with invalid handles
Change-Id: I6fbfa06e3df9988254561bf1a770084028117005 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/application.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 09111e6339d..052a3e4f79c 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -47,6 +47,14 @@ app_listener_get (application_t * app, u32 app_listener_index)
return pool_elt_at_index (app->listeners, app_listener_index);
}
+static app_listener_t *
+app_listener_get_if_valid (application_t * app, u32 app_listener_index)
+{
+ if (pool_is_free_index (app->listeners, app_listener_index))
+ return 0;
+ return pool_elt_at_index (app->listeners, app_listener_index);
+}
+
static void
app_listener_free (application_t * app, app_listener_t * app_listener)
{
@@ -94,7 +102,7 @@ app_listener_get_w_id (u32 listener_id)
app = application_get_if_valid (app_index);
if (!app)
return 0;
- return app_listener_get (app, app_listener_index);
+ return app_listener_get_if_valid (app, app_listener_index);
}
app_listener_t *
@@ -1060,7 +1068,9 @@ vnet_unlisten (vnet_unlisten_args_t * a)
if (!(app = application_get_if_valid (a->app_index)))
return VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
- al = app_listener_get_w_handle (a->handle);
+ if (!(al = app_listener_get_w_handle (a->handle)))
+ return -1;
+
if (al->app_index != app->app_index)
{
clib_warning ("app doesn't own handle %llu!", a->handle);