summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2021-10-21 08:30:15 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2021-10-21 08:30:15 +0000
commit4b60924a6c224e2475928674b9652efc5e85bcbf (patch)
tree8ef38ea9aefdf5a51ff566842573c3b755ee3f69 /lib
parentdeb5a86e45dae6ddbd35b2fc373fb617d183dbd2 (diff)
Avoid potential NULL dereferences in dtls1_free()
ok jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libssl/d1_lib.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libssl/d1_lib.c b/lib/libssl/d1_lib.c
index d4280a277c2..ec68b25140f 100644
--- a/lib/libssl/d1_lib.c
+++ b/lib/libssl/d1_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: d1_lib.c,v 1.59 2021/08/30 19:12:25 jsing Exp $ */
+/* $OpenBSD: d1_lib.c,v 1.60 2021/10/21 08:30:14 tb Exp $ */
/*
* DTLS implementation written by Nagendra Modadugu
* (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -154,6 +154,11 @@ dtls1_free(SSL *s)
ssl3_free(s);
+ if (s->d1 == NULL)
+ return;
+ if (D1I(s) == NULL)
+ goto out;
+
dtls1_clear_queues(s);
pqueue_free(D1I(s)->unprocessed_rcds.q);
@@ -161,9 +166,9 @@ dtls1_free(SSL *s)
pqueue_free(s->d1->sent_messages);
pqueue_free(D1I(s)->buffered_app_data.q);
+ out:
freezero(s->d1->internal, sizeof(*s->d1->internal));
freezero(s->d1, sizeof(*s->d1));
-
s->d1 = NULL;
}