Fossil SCM
When using HTTPS combined with HTTP AUTH, the SSL connection may go away and any further operations on it, including the implied SSL_shutdown() that occurs as a result of BIO_reset() or BIO_free_all() will crash Fossil. Attempt to deal with this by signaling a quiet shutdown if SSL_peek() returns an error.
Commit
616de1fef2a912f2291e135a49eec087ecbfafd3f679a4c60705f73401dba66e
Parent
ea66927c0cb112a…
1 file changed
+11
+11
| --- src/http_ssl.c | ||
| +++ src/http_ssl.c | ||
| @@ -168,11 +168,22 @@ | ||
| 168 | 168 | /* |
| 169 | 169 | ** Close the currently open SSL connection. If no connection is open, |
| 170 | 170 | ** this routine is a no-op. |
| 171 | 171 | */ |
| 172 | 172 | void ssl_close(void){ |
| 173 | + char buf[1]; | |
| 174 | + int ret; | |
| 173 | 175 | if( iBio!=NULL ){ |
| 176 | + if( (ret=SSL_peek(ssl,buf,sizeof(buf)))<=0 ){ | |
| 177 | + switch( SSL_get_error(ssl,ret) ){ | |
| 178 | + case SSL_ERROR_SYSCALL: | |
| 179 | + case SSL_ERROR_SSL: { | |
| 180 | + SSL_set_quiet_shutdown(ssl,1); | |
| 181 | + break; | |
| 182 | + } | |
| 183 | + } | |
| 184 | + } | |
| 174 | 185 | (void)BIO_reset(iBio); |
| 175 | 186 | BIO_free_all(iBio); |
| 176 | 187 | iBio = NULL; |
| 177 | 188 | } |
| 178 | 189 | } |
| 179 | 190 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -168,11 +168,22 @@ | |
| 168 | /* |
| 169 | ** Close the currently open SSL connection. If no connection is open, |
| 170 | ** this routine is a no-op. |
| 171 | */ |
| 172 | void ssl_close(void){ |
| 173 | if( iBio!=NULL ){ |
| 174 | (void)BIO_reset(iBio); |
| 175 | BIO_free_all(iBio); |
| 176 | iBio = NULL; |
| 177 | } |
| 178 | } |
| 179 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -168,11 +168,22 @@ | |
| 168 | /* |
| 169 | ** Close the currently open SSL connection. If no connection is open, |
| 170 | ** this routine is a no-op. |
| 171 | */ |
| 172 | void ssl_close(void){ |
| 173 | char buf[1]; |
| 174 | int ret; |
| 175 | if( iBio!=NULL ){ |
| 176 | if( (ret=SSL_peek(ssl,buf,sizeof(buf)))<=0 ){ |
| 177 | switch( SSL_get_error(ssl,ret) ){ |
| 178 | case SSL_ERROR_SYSCALL: |
| 179 | case SSL_ERROR_SSL: { |
| 180 | SSL_set_quiet_shutdown(ssl,1); |
| 181 | break; |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | (void)BIO_reset(iBio); |
| 186 | BIO_free_all(iBio); |
| 187 | iBio = NULL; |
| 188 | } |
| 189 | } |
| 190 |