diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-04-26 23:00:07 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-04-26 23:00:07 +0000 |
commit | ad07c62938e6b905db5ca6468bb2c5f211300e5c (patch) | |
tree | ba393231ddb00e2e8eb0fbbbf4f2df6a08891447 /src/common | |
parent | e34c201bb3678891c425f8db615759003ff77649 (diff) | |
download | tor-ad07c62938e6b905db5ca6468bb2c5f211300e5c.tar tor-ad07c62938e6b905db5ca6468bb2c5f211300e5c.tar.gz |
Add a macro to catch unhandled openssl errors.
svn:r1723
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/tortls.c | 12 | ||||
-rw-r--r-- | src/common/tortls.h | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c index f3183190d..738556d24 100644 --- a/src/common/tortls.c +++ b/src/common/tortls.c @@ -618,6 +618,18 @@ unsigned long tor_tls_get_n_bytes_written(tor_tls *tls) return BIO_number_written(SSL_get_wbio(tls->ssl)); } +void _assert_no_tls_errors(const char *fname, int line) +{ + if (ERR_peek_error() == 0) + return; + log_fn(LOG_ERR, "Unhandled OpenSSL errors found at %s:%d: ", + fname, line); + tls_log_errors(LOG_ERR, NULL); + + tor_assert(0); +} + + /* Local Variables: mode:c diff --git a/src/common/tortls.h b/src/common/tortls.h index da22454f2..c0099c944 100644 --- a/src/common/tortls.h +++ b/src/common/tortls.h @@ -33,6 +33,10 @@ int tor_tls_get_pending_bytes(tor_tls *tls); unsigned long tor_tls_get_n_bytes_read(tor_tls *tls); unsigned long tor_tls_get_n_bytes_written(tor_tls *tls); +#define assert_no_tls_errors() _assert_no_tls_errors(__FILE__,__LINE__); + +void _assert_no_tls_errors(const char *fname, int line); + #endif /* |