summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2022-07-28 08:39:13 +0000
committerFilip Tehlar <ftehlar@cisco.com>2022-07-28 15:38:18 +0000
commit92d296551bdc30900fcffcd9f837746b5c829e48 (patch)
treeff67d78e4b9dcd3d8441e945fa25a5362229038c
parent4a817a5d7eb248434987e1c99c23a5dfcf6c7f56 (diff)
session: fix a crash when using unregistered transport proto
Type: improvement Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: I39e3e007da2b99321bebf3e1c1ebb1d87547f532
-rw-r--r--src/vnet/session/session_types.h3
-rw-r--r--src/vnet/session/transport.c4
2 files changed, 6 insertions, 1 deletions
diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h
index 7cfa6716187..95a88c5ab6e 100644
--- a/src/vnet/session/session_types.h
+++ b/src/vnet/session/session_types.h
@@ -505,7 +505,8 @@ STATIC_ASSERT (sizeof (session_dgram_hdr_t) == (SESSION_CONN_ID_LEN + 8),
_ (NOEXTCFG, "no extended transport config") \
_ (NOCRYPTOENG, "no crypto engine") \
_ (NOCRYPTOCKP, "cert key pair not found ") \
- _ (LOCAL_CONNECT, "could not connect with local scope")
+ _ (LOCAL_CONNECT, "could not connect with local scope") \
+ _ (TRANSPORT_NO_REG, "transport was not registered")
typedef enum session_error_p_
{
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index 54ce9176666..192a201612a 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -314,6 +314,8 @@ transport_cleanup_half_open (transport_proto_t tp, u32 conn_index)
int
transport_connect (transport_proto_t tp, transport_endpoint_cfg_t * tep)
{
+ if (PREDICT_FALSE (!tp_vfts[tp].connect))
+ return SESSION_E_TRANSPORT_NO_REG;
return tp_vfts[tp].connect (tep);
}
@@ -343,6 +345,8 @@ u32
transport_start_listen (transport_proto_t tp, u32 session_index,
transport_endpoint_cfg_t *tep)
{
+ if (PREDICT_FALSE (!tp_vfts[tp].start_listen))
+ return SESSION_E_TRANSPORT_NO_REG;
return tp_vfts[tp].start_listen (session_index, tep);
}