Fossil SCM

Fix overlength lines and commenting irregularities in http_ssl.c. No code changes.

drh 2020-04-26 20:41 trunk
Commit 483ac3db837246c956ac009ed816d2d067780df8234a5d99257ffd5277a1cd9a
1 file changed +18 -9
+18 -9
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -185,11 +185,12 @@
185185
Blob snd, reply;
186186
int done=0,end=0;
187187
blob_zero(&snd);
188188
blob_appendf(&snd, "CONNECT %s:%d HTTP/1.1\r\n", pUrlData->hostname,
189189
pUrlData->proxyOrigPort);
190
- blob_appendf(&snd, "Host: %s:%d\r\n", pUrlData->hostname, pUrlData->proxyOrigPort);
190
+ blob_appendf(&snd, "Host: %s:%d\r\n",
191
+ pUrlData->hostname, pUrlData->proxyOrigPort);
191192
if( pUrlData->proxyAuth ){
192193
blob_appendf(&snd, "Proxy-Authorization: %s\r\n", pUrlData->proxyAuth);
193194
}
194195
blob_append(&snd, "Proxy-Connection: keep-alive\r\n", -1);
195196
blob_appendf(&snd, "User-Agent: %s\r\n", get_user_agent());
@@ -258,11 +259,12 @@
258259
char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
259260
BIO *sBio = BIO_new_connect(connStr);
260261
free(connStr);
261262
if( BIO_do_connect(sBio)<=0 ){
262263
ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)",
263
- pUrlData->name, pUrlData->port, ERR_reason_error_string(ERR_get_error()));
264
+ pUrlData->name, pUrlData->port,
265
+ ERR_reason_error_string(ERR_get_error()));
264266
ssl_close();
265267
return 1;
266268
}
267269
rc = establish_proxy_tunnel(pUrlData, sBio);
268270
if( rc<200||rc>299 ){
@@ -283,11 +285,13 @@
283285
return 1;
284286
}
285287
BIO_get_ssl(iBio, &ssl);
286288
287289
#if (SSLEAY_VERSION_NUMBER >= 0x00908070) && !defined(OPENSSL_NO_TLSEXT)
288
- if( !SSL_set_tlsext_host_name(ssl, (pUrlData->useProxy?pUrlData->hostname:pUrlData->name)) ){
290
+ if( !SSL_set_tlsext_host_name(ssl,
291
+ (pUrlData->useProxy?pUrlData->hostname:pUrlData->name))
292
+ ){
289293
fossil_warning("WARNING: failed to set server name indication (SNI), "
290294
"continuing without it.\n");
291295
}
292296
#endif
293297
@@ -297,11 +301,12 @@
297301
char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
298302
BIO_set_conn_hostname(iBio, connStr);
299303
free(connStr);
300304
if( BIO_do_connect(iBio)<=0 ){
301305
ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)",
302
- pUrlData->name, pUrlData->port, ERR_reason_error_string(ERR_get_error()));
306
+ pUrlData->name, pUrlData->port,
307
+ ERR_reason_error_string(ERR_get_error()));
303308
ssl_close();
304309
return 1;
305310
}
306311
}
307312
@@ -388,13 +393,15 @@
388393
/* Set the Global.zIpAddr variable to the server we are talking to.
389394
** This is used to populate the ipaddr column of the rcvfrom table,
390395
** if any files are received from the server.
391396
*/
392397
{
393
- /* As soon as libressl implements BIO_ADDR_hostname_string/BIO_get_conn_address.
394
- * check here for the correct LIBRESSL_VERSION_NUMBER too. For now: disable */
395
- #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L \
398
+ /* As soon as libressl implements
399
+ ** BIO_ADDR_hostname_string/BIO_get_conn_address.
400
+ ** check here for the correct LIBRESSL_VERSION_NUMBER too. For now: disable
401
+ */
402
+#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L \
396403
&& !defined(LIBRESSL_VERSION_NUMBER)
397404
char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1);
398405
g.zIpAddr = mprintf("%s", ip);
399406
OPENSSL_free(ip);
400407
#else
@@ -418,14 +425,16 @@
418425
419426
mem = BIO_new(BIO_s_mem());
420427
PEM_write_bio_X509(mem, cert);
421428
BIO_write(mem, "", 1); /* nul-terminate mem buffer */
422429
BIO_get_mem_data(mem, &zCert);
423
- zHost = mprintf("cert:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name);
430
+ zHost = mprintf("cert:%s",
431
+ pUrlData->useProxy ? pUrlData->hostname : pUrlData->name);
424432
db_set(zHost, zCert, 1);
425433
free(zHost);
426
- zHost = mprintf("trusted:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name);
434
+ zHost = mprintf("trusted:%s",
435
+ pUrlData->useProxy ? pUrlData->hostname : pUrlData->name);
427436
db_set_int(zHost, trusted, 1);
428437
free(zHost);
429438
BIO_free(mem);
430439
}
431440
432441
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -185,11 +185,12 @@
185 Blob snd, reply;
186 int done=0,end=0;
187 blob_zero(&snd);
188 blob_appendf(&snd, "CONNECT %s:%d HTTP/1.1\r\n", pUrlData->hostname,
189 pUrlData->proxyOrigPort);
190 blob_appendf(&snd, "Host: %s:%d\r\n", pUrlData->hostname, pUrlData->proxyOrigPort);
 
191 if( pUrlData->proxyAuth ){
192 blob_appendf(&snd, "Proxy-Authorization: %s\r\n", pUrlData->proxyAuth);
193 }
194 blob_append(&snd, "Proxy-Connection: keep-alive\r\n", -1);
195 blob_appendf(&snd, "User-Agent: %s\r\n", get_user_agent());
@@ -258,11 +259,12 @@
258 char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
259 BIO *sBio = BIO_new_connect(connStr);
260 free(connStr);
261 if( BIO_do_connect(sBio)<=0 ){
262 ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)",
263 pUrlData->name, pUrlData->port, ERR_reason_error_string(ERR_get_error()));
 
264 ssl_close();
265 return 1;
266 }
267 rc = establish_proxy_tunnel(pUrlData, sBio);
268 if( rc<200||rc>299 ){
@@ -283,11 +285,13 @@
283 return 1;
284 }
285 BIO_get_ssl(iBio, &ssl);
286
287 #if (SSLEAY_VERSION_NUMBER >= 0x00908070) && !defined(OPENSSL_NO_TLSEXT)
288 if( !SSL_set_tlsext_host_name(ssl, (pUrlData->useProxy?pUrlData->hostname:pUrlData->name)) ){
 
 
289 fossil_warning("WARNING: failed to set server name indication (SNI), "
290 "continuing without it.\n");
291 }
292 #endif
293
@@ -297,11 +301,12 @@
297 char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
298 BIO_set_conn_hostname(iBio, connStr);
299 free(connStr);
300 if( BIO_do_connect(iBio)<=0 ){
301 ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)",
302 pUrlData->name, pUrlData->port, ERR_reason_error_string(ERR_get_error()));
 
303 ssl_close();
304 return 1;
305 }
306 }
307
@@ -388,13 +393,15 @@
388 /* Set the Global.zIpAddr variable to the server we are talking to.
389 ** This is used to populate the ipaddr column of the rcvfrom table,
390 ** if any files are received from the server.
391 */
392 {
393 /* As soon as libressl implements BIO_ADDR_hostname_string/BIO_get_conn_address.
394 * check here for the correct LIBRESSL_VERSION_NUMBER too. For now: disable */
395 #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L \
 
 
396 && !defined(LIBRESSL_VERSION_NUMBER)
397 char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1);
398 g.zIpAddr = mprintf("%s", ip);
399 OPENSSL_free(ip);
400 #else
@@ -418,14 +425,16 @@
418
419 mem = BIO_new(BIO_s_mem());
420 PEM_write_bio_X509(mem, cert);
421 BIO_write(mem, "", 1); /* nul-terminate mem buffer */
422 BIO_get_mem_data(mem, &zCert);
423 zHost = mprintf("cert:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name);
 
424 db_set(zHost, zCert, 1);
425 free(zHost);
426 zHost = mprintf("trusted:%s", pUrlData->useProxy?pUrlData->hostname:pUrlData->name);
 
427 db_set_int(zHost, trusted, 1);
428 free(zHost);
429 BIO_free(mem);
430 }
431
432
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -185,11 +185,12 @@
185 Blob snd, reply;
186 int done=0,end=0;
187 blob_zero(&snd);
188 blob_appendf(&snd, "CONNECT %s:%d HTTP/1.1\r\n", pUrlData->hostname,
189 pUrlData->proxyOrigPort);
190 blob_appendf(&snd, "Host: %s:%d\r\n",
191 pUrlData->hostname, pUrlData->proxyOrigPort);
192 if( pUrlData->proxyAuth ){
193 blob_appendf(&snd, "Proxy-Authorization: %s\r\n", pUrlData->proxyAuth);
194 }
195 blob_append(&snd, "Proxy-Connection: keep-alive\r\n", -1);
196 blob_appendf(&snd, "User-Agent: %s\r\n", get_user_agent());
@@ -258,11 +259,12 @@
259 char *connStr = mprintf("%s:%d", g.url.name, pUrlData->port);
260 BIO *sBio = BIO_new_connect(connStr);
261 free(connStr);
262 if( BIO_do_connect(sBio)<=0 ){
263 ssl_set_errmsg("SSL: cannot connect to proxy %s:%d (%s)",
264 pUrlData->name, pUrlData->port,
265 ERR_reason_error_string(ERR_get_error()));
266 ssl_close();
267 return 1;
268 }
269 rc = establish_proxy_tunnel(pUrlData, sBio);
270 if( rc<200||rc>299 ){
@@ -283,11 +285,13 @@
285 return 1;
286 }
287 BIO_get_ssl(iBio, &ssl);
288
289 #if (SSLEAY_VERSION_NUMBER >= 0x00908070) && !defined(OPENSSL_NO_TLSEXT)
290 if( !SSL_set_tlsext_host_name(ssl,
291 (pUrlData->useProxy?pUrlData->hostname:pUrlData->name))
292 ){
293 fossil_warning("WARNING: failed to set server name indication (SNI), "
294 "continuing without it.\n");
295 }
296 #endif
297
@@ -297,11 +301,12 @@
301 char *connStr = mprintf("%s:%d", pUrlData->name, pUrlData->port);
302 BIO_set_conn_hostname(iBio, connStr);
303 free(connStr);
304 if( BIO_do_connect(iBio)<=0 ){
305 ssl_set_errmsg("SSL: cannot connect to host %s:%d (%s)",
306 pUrlData->name, pUrlData->port,
307 ERR_reason_error_string(ERR_get_error()));
308 ssl_close();
309 return 1;
310 }
311 }
312
@@ -388,13 +393,15 @@
393 /* Set the Global.zIpAddr variable to the server we are talking to.
394 ** This is used to populate the ipaddr column of the rcvfrom table,
395 ** if any files are received from the server.
396 */
397 {
398 /* As soon as libressl implements
399 ** BIO_ADDR_hostname_string/BIO_get_conn_address.
400 ** check here for the correct LIBRESSL_VERSION_NUMBER too. For now: disable
401 */
402 #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L \
403 && !defined(LIBRESSL_VERSION_NUMBER)
404 char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1);
405 g.zIpAddr = mprintf("%s", ip);
406 OPENSSL_free(ip);
407 #else
@@ -418,14 +425,16 @@
425
426 mem = BIO_new(BIO_s_mem());
427 PEM_write_bio_X509(mem, cert);
428 BIO_write(mem, "", 1); /* nul-terminate mem buffer */
429 BIO_get_mem_data(mem, &zCert);
430 zHost = mprintf("cert:%s",
431 pUrlData->useProxy ? pUrlData->hostname : pUrlData->name);
432 db_set(zHost, zCert, 1);
433 free(zHost);
434 zHost = mprintf("trusted:%s",
435 pUrlData->useProxy ? pUrlData->hostname : pUrlData->name);
436 db_set_int(zHost, trusted, 1);
437 free(zHost);
438 BIO_free(mem);
439 }
440
441

Keyboard Shortcuts

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