diff options
author | 2015-03-27 12:29:54 +0000 | |
---|---|---|
committer | 2015-03-27 12:29:54 +0000 | |
commit | 4c5ec7da26a11a298d79cded54aa76d431fdda94 (patch) | |
tree | 59e19ccbcd28ea53aebc59248e7f35610a5d20e4 /lib/libssl/s3_both.c | |
parent | BUF_MEM_free() has its own explicit NULL check. (diff) | |
download | wireguard-openbsd-4c5ec7da26a11a298d79cded54aa76d431fdda94.tar.xz wireguard-openbsd-4c5ec7da26a11a298d79cded54aa76d431fdda94.zip |
Factor out the init_buf initialisation code, rather than duplicating it
in four different places.
ok doug@ guenther@
Diffstat (limited to 'lib/libssl/s3_both.c')
-rw-r--r-- | lib/libssl/s3_both.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/libssl/s3_both.c b/lib/libssl/s3_both.c index a2ce9e9fa3a..633bf5bb7b9 100644 --- a/lib/libssl/s3_both.c +++ b/lib/libssl/s3_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_both.c,v 1.37 2014/12/14 21:49:29 bcook Exp $ */ +/* $OpenBSD: s3_both.c,v 1.38 2015/03/27 12:29:54 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -607,6 +607,27 @@ ssl_verify_alarm_type(long type) } int +ssl3_setup_init_buffer(SSL *s) +{ + BUF_MEM *buf = NULL; + + if (s->init_buf != NULL) + return (1); + + if ((buf = BUF_MEM_new()) == NULL) + goto err; + if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) + goto err; + + s->init_buf = buf; + return (1); + +err: + BUF_MEM_free(buf); + return (0); +} + +int ssl3_setup_read_buffer(SSL *s) { unsigned char *p; @@ -673,7 +694,6 @@ err: return 0; } - int ssl3_setup_buffers(SSL *s) { @@ -699,4 +719,3 @@ ssl3_release_read_buffer(SSL *s) s->s3->rbuf.buf = NULL; return 1; } - |