From 4c2c25f80b3cc173f09f6113e0ee623866948b87 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Fri, 24 May 2024 23:02:22 +0200 Subject: deallocate connection on conn open failure --- ecp/server/dir.c | 6 +++++- ecp/server/vlink.c | 5 ++++- ecp/server/vlink.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'ecp') diff --git a/ecp/server/dir.c b/ecp/server/dir.c index c045599..b941050 100644 --- a/ecp/server/dir.c +++ b/ecp/server/dir.c @@ -497,7 +497,10 @@ int dir_open_conn(DIRNode *node, ECPSocket *sock) { ecp_conn_set_flags(node->conn, ECP_CONN_FLAG_VBOX); rv = ecp_conn_open(node->conn, &node->dir_item.node); - if (rv) node->conn = NULL; + if (rv) { + free(node->conn); + node->conn = NULL; + } return rv; } @@ -932,6 +935,7 @@ int dir_init_ann(ECPSocket *sock, ECPNode *node) { ecp_conn_set_flags(conn, ECP_CONN_FLAG_VBOX); rv = ecp_conn_open(conn, node); if (rv) { + free(conn); LOG(LOG_ERR, "dir_init_ann: conn open err:%d\n", rv); return rv; } diff --git a/ecp/server/vlink.c b/ecp/server/vlink.c index fcb9a5c..445734c 100644 --- a/ecp/server/vlink.c +++ b/ecp/server/vlink.c @@ -33,7 +33,10 @@ int vlink_open_conn(ECPSocket *sock, ECPNode *node, ECPConnection **_conn) { ecp_vlink_init(conn, sock); rv = ecp_conn_open(conn, node); - if (rv) return rv; + if (rv) { + free(conn); + return rv; + } *_conn = conn; return ECP_OK; diff --git a/ecp/server/vlink.h b/ecp/server/vlink.h index 3e8022f..b591d11 100644 --- a/ecp/server/vlink.h +++ b/ecp/server/vlink.h @@ -1,6 +1,7 @@ #define MAX_KEYX_CNT 100 #define KEYX_PERIOD 600 /* key exchange priod (s); can't exceed 1h */ + #define VLINK_UFLAG_DISCONNECT 0x80 int vlink_open_conn(ECPSocket *sock, ECPNode *node, ECPConnection **_conn); -- cgit v1.2.3