aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelva Nair2023-03-27 13:12:36 -0400
committerGert Doering2023-03-28 09:09:42 +0200
commitd01b9d751d6a5b4dc3737b339ec1ca5c23705243 (patch)
tree8386eab53c08f150462f9996b10eea21e9e85657
parent3577442530eb7830709538a2e21282b98a97d4f2 (diff)
downloadopenvpn-d01b9d751d6a5b4dc3737b339ec1ca5c23705243.zip
openvpn-d01b9d751d6a5b4dc3737b339ec1ca5c23705243.tar.gz
Bug-fix: segfault in dco_get_peer_stats()
We persist peer-stats when restarting, but an early restart before open_tun results in a segfault in dco_get_peer_stats(). To reproduce, trigger a TLS handshake error due to lack of common protocols, for example. Fix by checking that tuntap is defined before dereferencing it. Signed-off-by: Selva Nair <selva.nair@gmail.com> Acked-by: Antonio Quartulli <a@unstable.cc> Message-Id: <20230327171236.51771-1-selva.nair@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26530.html Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit 10c3f25a26bce480f80624c5ef4cb6774a31c305)
-rw-r--r--src/openvpn/dco_linux.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c
index 317f9dc..41540c0 100644
--- a/src/openvpn/dco_linux.c
+++ b/src/openvpn/dco_linux.c
@@ -975,6 +975,11 @@ dco_get_peer_stats(struct context *c)
uint32_t peer_id = c->c2.tls_multi->dco_peer_id;
msg(D_DCO_DEBUG, "%s: peer-id %d", __func__, peer_id);
+ if (!c->c1.tuntap)
+ {
+ return 0;
+ }
+
dco_context_t *dco = &c->c1.tuntap->dco;
struct nl_msg *nl_msg = ovpn_dco_nlmsg_create(dco, OVPN_CMD_GET_PEER);
struct nlattr *attr = nla_nest_start(nl_msg, OVPN_ATTR_GET_PEER);