diff options
author | Steffan Karger <steffan@karger.me> | 2015-05-03 14:06:01 +0200 |
---|---|---|
committer | Gert Doering <gert@greenie.muc.de> | 2015-05-03 14:39:37 +0200 |
commit | 23b6ba6378bf3a3f5ceb828c8a4dd7cc38947d07 (patch) | |
tree | 323e6d02ca59f0e4f955379f0601cfce4e66fd9c | |
parent | d55be0fb8091ff03af1319a27f68401d31ce8571 (diff) | |
download | openvpn-23b6ba6378bf3a3f5ceb828c8a4dd7cc38947d07.tar.gz openvpn-23b6ba6378bf3a3f5ceb828c8a4dd7cc38947d07.tar.xz openvpn-23b6ba6378bf3a3f5ceb828c8a4dd7cc38947d07.zip |
polarssl: remove code duplication in key_state_write_plaintext{, _const}()
Both functions had almost exactly the same code. Instead of the code
duplication, have key_state_write_plaintext() call
key_state_write_plaintext_const() to do the actual work. This is just
a bit of cleanup, it should not change any behaviour.
Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1430654761-26563-2-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9640
Signed-off-by: Gert Doering <gert@greenie.muc.de>
-rw-r--r-- | src/openvpn/ssl_polarssl.c | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/src/openvpn/ssl_polarssl.c b/src/openvpn/ssl_polarssl.c index 8cb328e..913585d 100644 --- a/src/openvpn/ssl_polarssl.c +++ b/src/openvpn/ssl_polarssl.c @@ -838,46 +838,18 @@ int key_state_write_plaintext (struct key_state_ssl *ks, struct buffer *buf) { int retval = 0; - perf_push (PERF_BIO_WRITE_PLAINTEXT); - ASSERT (NULL != ks); ASSERT (buf); - ASSERT (buf->len >= 0); - if (0 == buf->len) - { - perf_pop (); - return 0; - } - - retval = ssl_write(ks->ctx, BPTR(buf), buf->len); - - if (retval < 0) - { - perf_pop (); - if (POLARSSL_ERR_NET_WANT_WRITE == retval || POLARSSL_ERR_NET_WANT_READ == retval) - return 0; - msg (D_TLS_ERRORS, "TLS ERROR: write tls_write_plaintext error"); - return -1; - } + retval = key_state_write_plaintext_const(ks, BPTR(buf), BLEN(buf)); - if (retval != buf->len) + if (1 == retval) { - msg (D_TLS_ERRORS, - "TLS ERROR: write tls_write_plaintext incomplete %d/%d", - retval, buf->len); - perf_pop (); - return -1; + memset (BPTR (buf), 0, BLEN (buf)); /* erase data just written */ + buf->len = 0; } - /* successful write */ - dmsg (D_HANDSHAKE_VERBOSE, "write tls_write_plaintext %d bytes", retval); - - memset (BPTR (buf), 0, BLEN (buf)); /* erase data just written */ - buf->len = 0; - - perf_pop (); - return 1; + return retval; } int |