diff options
author | 2020-09-24 17:59:54 +0000 | |
---|---|---|
committer | 2020-09-24 17:59:54 +0000 | |
commit | 435f94b74e31aaa328aa82ba94c8fdad60dbb4d7 (patch) | |
tree | 7386ada5c49e9ffdf8de1e0b91ddd85d53355dd2 /lib/libssl/ssl_both.c | |
parent | mi_ast() needs curcpu()->ci_want_resched rather than ci->ci_want_resched, (diff) | |
download | wireguard-openbsd-435f94b74e31aaa328aa82ba94c8fdad60dbb4d7.tar.xz wireguard-openbsd-435f94b74e31aaa328aa82ba94c8fdad60dbb4d7.zip |
Release read and write buffers using freezero().
Provide a ssl3_release_buffer() function that correctly frees a buffer
and call it from the appropriate locations. While here also change
ssl3_release_{read,write}_buffer() to void since they cannot fail and
no callers check the return value currently.
ok beck@ inoguchi@ tb@
Diffstat (limited to 'lib/libssl/ssl_both.c')
-rw-r--r-- | lib/libssl/ssl_both.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/libssl/ssl_both.c b/lib/libssl/ssl_both.c index 488a5ff7c93..dff44ecd415 100644 --- a/lib/libssl/ssl_both.c +++ b/lib/libssl/ssl_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_both.c,v 1.18 2020/05/19 16:35:20 jsing Exp $ */ +/* $OpenBSD: ssl_both.c,v 1.19 2020/09/24 17:59:54 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -708,7 +708,7 @@ ssl3_setup_read_buffer(SSL *s) S3I(s)->rbuf.len = len; } - s->internal->packet = &(S3I(s)->rbuf.buf[0]); + s->internal->packet = S3I(s)->rbuf.buf; return 1; err: @@ -759,18 +759,22 @@ ssl3_setup_buffers(SSL *s) return 1; } -int -ssl3_release_write_buffer(SSL *s) +void +ssl3_release_buffer(SSL3_BUFFER_INTERNAL *b) { - free(S3I(s)->wbuf.buf); - S3I(s)->wbuf.buf = NULL; - return 1; + freezero(b->buf, b->len); + b->buf = NULL; + b->len = 0; } -int +void ssl3_release_read_buffer(SSL *s) { - free(S3I(s)->rbuf.buf); - S3I(s)->rbuf.buf = NULL; - return 1; + ssl3_release_buffer(&S3I(s)->rbuf); +} + +void +ssl3_release_write_buffer(SSL *s) +{ + ssl3_release_buffer(&S3I(s)->wbuf); } |