summaryrefslogtreecommitdiff
path: root/src/lib/libssl/s3_lib.c
diff options
context:
space:
mode:
authorjsing <>2017-01-22 03:50:45 +0000
committerjsing <>2017-01-22 03:50:45 +0000
commitda11794e3abdcddc9079bb28bb8e44547030b01f (patch)
tree1305cf6ae8a5e82d3473b44db775f816b47c9554 /src/lib/libssl/s3_lib.c
parentbcd4033a22e1bf44686805b7d0fd9c2560c44eb4 (diff)
downloadopenbsd-da11794e3abdcddc9079bb28bb8e44547030b01f.tar.gz
openbsd-da11794e3abdcddc9079bb28bb8e44547030b01f.tar.bz2
openbsd-da11794e3abdcddc9079bb28bb8e44547030b01f.zip
Convert publically visible structs to translucent structs.
This change adds an internal opaque struct for each of the significant publically visible structs. The opaque struct is then allocated and attached to the publically visible struct when the appropriate *_new() function is called, then cleared and freed as necessary. This will allow for changes to be made to the internals of libssl, without requiring a major bump each time the publically visible structs are modified. ok beck@
Diffstat (limited to 'src/lib/libssl/s3_lib.c')
-rw-r--r--src/lib/libssl/s3_lib.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index 0dda987d4c..6f5ee4fa50 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_lib.c,v 1.117 2017/01/22 00:09:13 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.118 2017/01/22 03:50:45 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1811,6 +1811,10 @@ ssl3_new(SSL *s)
1811{ 1811{
1812 if ((s->s3 = calloc(1, sizeof(*s->s3))) == NULL) 1812 if ((s->s3 = calloc(1, sizeof(*s->s3))) == NULL)
1813 return (0); 1813 return (0);
1814 if ((s->s3->internal = calloc(1, sizeof(*s->s3->internal))) == NULL) {
1815 free(s->s3);
1816 return (0);
1817 }
1814 1818
1815 s->method->ssl_clear(s); 1819 s->method->ssl_clear(s);
1816 1820
@@ -1840,14 +1844,19 @@ ssl3_free(SSL *s)
1840 tls1_free_digest_list(s); 1844 tls1_free_digest_list(s);
1841 free(s->s3->alpn_selected); 1845 free(s->s3->alpn_selected);
1842 1846
1843 explicit_bzero(s->s3, sizeof *s->s3); 1847 explicit_bzero(s->s3->internal, sizeof(*s->s3->internal));
1848 free(s->s3->internal);
1849
1850 explicit_bzero(s->s3, sizeof(*s->s3));
1844 free(s->s3); 1851 free(s->s3);
1852
1845 s->s3 = NULL; 1853 s->s3 = NULL;
1846} 1854}
1847 1855
1848void 1856void
1849ssl3_clear(SSL *s) 1857ssl3_clear(SSL *s)
1850{ 1858{
1859 struct ssl3_state_internal_st *internal;
1851 unsigned char *rp, *wp; 1860 unsigned char *rp, *wp;
1852 size_t rlen, wlen; 1861 size_t rlen, wlen;
1853 1862
@@ -1878,7 +1887,10 @@ ssl3_clear(SSL *s)
1878 free(s->s3->alpn_selected); 1887 free(s->s3->alpn_selected);
1879 s->s3->alpn_selected = NULL; 1888 s->s3->alpn_selected = NULL;
1880 1889
1881 memset(s->s3, 0, sizeof *s->s3); 1890 memset(s->s3->internal, 0, sizeof(*s->s3->internal));
1891 internal = s->s3->internal;
1892 memset(s->s3, 0, sizeof(*s->s3));
1893 s->s3->internal = internal;
1882 1894
1883 s->s3->rbuf.buf = rp; 1895 s->s3->rbuf.buf = rp;
1884 s->s3->wbuf.buf = wp; 1896 s->s3->wbuf.buf = wp;