Skip to content

Commit f6dfcf8

Browse files
author
Lukasz Osipiuk
committed
Add call ERR_clear_error() before SSL_* calls
SSL_get_error function requires calling ERR_clear_error queue before executing function which error code is to be determined. Otherwise spurious error codes may be returned even for successful operations. http://www.openssl.org/docs/ssl/SSL_get_error.html
1 parent 84797cc commit f6dfcf8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

stud.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,7 @@ static void client_handshake(struct ev_loop *loop, ev_io *w, int revents) {
996996
int t;
997997
proxystate *ps = (proxystate *)w->data;
998998

999+
ERR_clear_error();
9991000
t = SSL_do_handshake(ps->ssl);
10001001
if (t == 1) {
10011002
end_handshake(ps);
@@ -1046,6 +1047,7 @@ static void ssl_read(struct ev_loop *loop, ev_io *w, int revents) {
10461047
return;
10471048
}
10481049
char * buf = ringbuffer_write_ptr(&ps->ring_ssl2clear);
1050+
ERR_clear_error();
10491051
t = SSL_read(ps->ssl, buf, RING_DATA_LEN);
10501052

10511053
/* Fix CVE-2009-3555. Disable reneg if started by client. */
@@ -1081,6 +1083,7 @@ static void ssl_write(struct ev_loop *loop, ev_io *w, int revents) {
10811083
proxystate *ps = (proxystate *)w->data;
10821084
assert(!ringbuffer_is_empty(&ps->ring_clear2ssl));
10831085
char * next = ringbuffer_read_next(&ps->ring_clear2ssl, &sz);
1086+
ERR_clear_error();
10841087
t = SSL_write(ps->ssl, next, sz);
10851088
if (t > 0) {
10861089
if (t == sz) {

0 commit comments

Comments
 (0)