@@ -3002,72 +3002,69 @@ int SSL_get_error(const SSL *s, int i)
30023002 return (SSL_ERROR_SSL );
30033003 }
30043004
3005- if (i < 0 ) {
3006- if (SSL_want_read (s )) {
3007- bio = SSL_get_rbio (s );
3008- if (BIO_should_read (bio ))
3009- return (SSL_ERROR_WANT_READ );
3010- else if (BIO_should_write (bio ))
3011- /*
3012- * This one doesn't make too much sense ... We never try to write
3013- * to the rbio, and an application program where rbio and wbio
3014- * are separate couldn't even know what it should wait for.
3015- * However if we ever set s->rwstate incorrectly (so that we have
3016- * SSL_want_read(s) instead of SSL_want_write(s)) and rbio and
3017- * wbio *are* the same, this test works around that bug; so it
3018- * might be safer to keep it.
3019- */
3020- return (SSL_ERROR_WANT_WRITE );
3021- else if (BIO_should_io_special (bio )) {
3022- reason = BIO_get_retry_reason (bio );
3023- if (reason == BIO_RR_CONNECT )
3024- return (SSL_ERROR_WANT_CONNECT );
3025- else if (reason == BIO_RR_ACCEPT )
3026- return (SSL_ERROR_WANT_ACCEPT );
3027- else
3028- return (SSL_ERROR_SYSCALL ); /* unknown */
3029- }
3005+ if (SSL_want_read (s )) {
3006+ bio = SSL_get_rbio (s );
3007+ if (BIO_should_read (bio ))
3008+ return (SSL_ERROR_WANT_READ );
3009+ else if (BIO_should_write (bio ))
3010+ /*
3011+ * This one doesn't make too much sense ... We never try to write
3012+ * to the rbio, and an application program where rbio and wbio
3013+ * are separate couldn't even know what it should wait for.
3014+ * However if we ever set s->rwstate incorrectly (so that we have
3015+ * SSL_want_read(s) instead of SSL_want_write(s)) and rbio and
3016+ * wbio *are* the same, this test works around that bug; so it
3017+ * might be safer to keep it.
3018+ */
3019+ return (SSL_ERROR_WANT_WRITE );
3020+ else if (BIO_should_io_special (bio )) {
3021+ reason = BIO_get_retry_reason (bio );
3022+ if (reason == BIO_RR_CONNECT )
3023+ return (SSL_ERROR_WANT_CONNECT );
3024+ else if (reason == BIO_RR_ACCEPT )
3025+ return (SSL_ERROR_WANT_ACCEPT );
3026+ else
3027+ return (SSL_ERROR_SYSCALL ); /* unknown */
30303028 }
3029+ }
30313030
3032- if (SSL_want_write (s )) {
3031+ if (SSL_want_write (s )) {
3032+ /*
3033+ * Access wbio directly - in order to use the buffered bio if
3034+ * present
3035+ */
3036+ bio = s -> wbio ;
3037+ if (BIO_should_write (bio ))
3038+ return (SSL_ERROR_WANT_WRITE );
3039+ else if (BIO_should_read (bio ))
30333040 /*
3034- * Access wbio directly - in order to use the buffered bio if
3035- * present
3041+ * See above (SSL_want_read(s) with BIO_should_write(bio))
30363042 */
3037- bio = s -> wbio ;
3038- if (BIO_should_write (bio ))
3039- return (SSL_ERROR_WANT_WRITE );
3040- else if (BIO_should_read (bio ))
3041- /*
3042- * See above (SSL_want_read(s) with BIO_should_write(bio))
3043- */
3044- return (SSL_ERROR_WANT_READ );
3045- else if (BIO_should_io_special (bio )) {
3046- reason = BIO_get_retry_reason (bio );
3047- if (reason == BIO_RR_CONNECT )
3048- return (SSL_ERROR_WANT_CONNECT );
3049- else if (reason == BIO_RR_ACCEPT )
3050- return (SSL_ERROR_WANT_ACCEPT );
3051- else
3052- return (SSL_ERROR_SYSCALL );
3053- }
3054- }
3055- if (SSL_want_x509_lookup (s )) {
3056- return (SSL_ERROR_WANT_X509_LOOKUP );
3057- }
3058- if (SSL_want_async (s )) {
3059- return SSL_ERROR_WANT_ASYNC ;
3060- }
3061- if (SSL_want_async_job (s )) {
3062- return SSL_ERROR_WANT_ASYNC_JOB ;
3043+ return (SSL_ERROR_WANT_READ );
3044+ else if (BIO_should_io_special (bio )) {
3045+ reason = BIO_get_retry_reason (bio );
3046+ if (reason == BIO_RR_CONNECT )
3047+ return (SSL_ERROR_WANT_CONNECT );
3048+ else if (reason == BIO_RR_ACCEPT )
3049+ return (SSL_ERROR_WANT_ACCEPT );
3050+ else
3051+ return (SSL_ERROR_SYSCALL );
30633052 }
30643053 }
3065-
3066- if (i == 0 ) {
3067- if ((s -> shutdown & SSL_RECEIVED_SHUTDOWN ) &&
3068- (s -> s3 -> warn_alert == SSL_AD_CLOSE_NOTIFY ))
3069- return (SSL_ERROR_ZERO_RETURN );
3054+ if (SSL_want_x509_lookup (s )) {
3055+ return (SSL_ERROR_WANT_X509_LOOKUP );
30703056 }
3057+ if (SSL_want_async (s )) {
3058+ return SSL_ERROR_WANT_ASYNC ;
3059+ }
3060+ if (SSL_want_async_job (s )) {
3061+ return SSL_ERROR_WANT_ASYNC_JOB ;
3062+ }
3063+
3064+ if ((s -> shutdown & SSL_RECEIVED_SHUTDOWN ) &&
3065+ (s -> s3 -> warn_alert == SSL_AD_CLOSE_NOTIFY ))
3066+ return (SSL_ERROR_ZERO_RETURN );
3067+
30713068 return (SSL_ERROR_SYSCALL );
30723069}
30733070
0 commit comments