Use freezero() for the internal opaque structures, instead of the current
authorjsing <jsing@openbsd.org>
Mon, 10 Apr 2017 17:27:33 +0000 (17:27 +0000)
committerjsing <jsing@openbsd.org>
Mon, 10 Apr 2017 17:27:33 +0000 (17:27 +0000)
explicit_bzero()/free(). Less code and potentially less overhead.

lib/libssl/d1_lib.c
lib/libssl/s3_lib.c
lib/libssl/ssl_sess.c

index 8092d56..7e919a6 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: d1_lib.c,v 1.41 2017/02/07 02:08:38 beck Exp $ */
+/* $OpenBSD: d1_lib.c,v 1.42 2017/04/10 17:27:33 jsing Exp $ */
 /*
  * DTLS implementation written by Nagendra Modadugu
  * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -191,11 +191,8 @@ dtls1_free(SSL *s)
        pqueue_free(s->d1->sent_messages);
        pqueue_free(D1I(s)->buffered_app_data.q);
 
-       explicit_bzero(s->d1->internal, sizeof(*s->d1->internal));
-       free(s->d1->internal);
-
-       explicit_bzero(s->d1, sizeof(*s->d1));
-       free(s->d1);
+       freezero(s->d1->internal, sizeof(*s->d1->internal));
+       freezero(s->d1, sizeof(*s->d1));
 
        s->d1 = NULL;
 }
index 1fd077e..d4142e7 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: s3_lib.c,v 1.139 2017/04/10 17:25:22 jsing Exp $ */
+/* $OpenBSD: s3_lib.c,v 1.140 2017/04/10 17:27:33 jsing Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -1844,11 +1844,8 @@ ssl3_free(SSL *s)
 
        free(S3I(s)->alpn_selected);
 
-       explicit_bzero(S3I(s), sizeof(*S3I(s)));
-       free(S3I(s));
-
-       explicit_bzero(s->s3, sizeof(*s->s3));
-       free(s->s3);
+       freezero(S3I(s), sizeof(*S3I(s)));
+       freezero(s->s3, sizeof(*s->s3));
 
        s->s3 = NULL;
 }
index 5d80e58..59d7d9e 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_sess.c,v 1.70 2017/02/07 02:08:38 beck Exp $ */
+/* $OpenBSD: ssl_sess.c,v 1.71 2017/04/10 17:27:33 jsing Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -705,11 +705,8 @@ SSL_SESSION_free(SSL_SESSION *ss)
        free(ss->internal->tlsext_ecpointformatlist);
        free(ss->internal->tlsext_supportedgroups);
 
-       explicit_bzero(ss->internal, sizeof(*ss->internal));
-       free(ss->internal);
-
-       explicit_bzero(ss, sizeof(*ss));
-       free(ss);
+       freezero(ss->internal, sizeof(*ss->internal));
+       freezero(ss, sizeof(*ss));
 }
 
 int