Skip to content

Commit

Permalink
Fix crash on DTLS resumption
Browse files Browse the repository at this point in the history
If the mainloop is paused and then resumed, DTLS will attempt to
reconnect at the same time as CSTP.  When DTLS-PSK is in use,
gnutls_prf() will be called on a NULL vpninfo->https_sess pointer.
Avoid this by deferring DTLS resumption until CSTP has reconnected, if
DTLS-PSK is in use.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
  • Loading branch information
cernekee committed Feb 12, 2018
1 parent fdaba77 commit c032fcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dtls.c
Expand Up @@ -265,7 +265,8 @@ int dtls_mainloop(struct openconnect_info *vpninfo, int *timeout)

if (when <= 0) {
vpn_progress(vpninfo, PRG_DEBUG, _("Attempt new DTLS connection\n"));
connect_dtls_socket(vpninfo);
if (connect_dtls_socket(vpninfo) < 0)
*timeout = 1000;
} else if ((when * 1000) < *timeout) {
*timeout = when * 1000;
}
Expand Down
6 changes: 6 additions & 0 deletions gnutls-dtls.c
Expand Up @@ -161,6 +161,12 @@ static int start_dtls_psk_handshake(struct openconnect_info *vpninfo, int dtls_f
struct oc_text_buf *prio;
int err;

if (!vpninfo->https_sess) {
vpn_progress(vpninfo, PRG_INFO,
_("Deferring DTLS resumption until CSTP generates a PSK\n"));
return -EAGAIN;
}

prio = buf_alloc();
buf_append(prio, "%s:-VERS-TLS-ALL:+VERS-DTLS-ALL:-KX-ALL:+PSK", vpninfo->gnutls_prio);
if (buf_error(prio)) {
Expand Down

0 comments on commit c032fcd

Please sign in to comment.