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.

andybradford 2020-02-06 15:32 trunk
Commit 616de1fef2a912f2291e135a49eec087ecbfafd3f679a4c60705f73401dba66e
1 file changed +11
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -168,11 +168,22 @@
168168
/*
169169
** Close the currently open SSL connection. If no connection is open,
170170
** this routine is a no-op.
171171
*/
172172
void ssl_close(void){
173
+ char buf[1];
174
+ int ret;
173175
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
+ }
174185
(void)BIO_reset(iBio);
175186
BIO_free_all(iBio);
176187
iBio = NULL;
177188
}
178189
}
179190
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button