Fossil SCM

Check for the presence of BIO_ADDR_hostname_string before using it.

andybradford 2019-03-25 14:02 trunk
Commit 0ef9501cfa0edd49a00f949b665402d638b7ec5491d8bcd33fe70ff7703d9d9d
2 files changed +4 +5 -5
+4
--- auto.def
+++ auto.def
@@ -375,10 +375,14 @@
375375
# Silence OpenSSL deprecation warnings on Mac OS X 10.7.
376376
if {[string match *-darwin* [get-define host]]} {
377377
if {[cctest -cflags {-Wdeprecated-declarations}]} {
378378
define-append EXTRA_CFLAGS -Wdeprecated-declarations
379379
}
380
+ }
381
+ if {[cc-check-function-in-lib BIO_ADDR_hostname_string ssl]} {
382
+ define HAVE_BIO_ADDR_HS 1
383
+ msg-result "Using BIO_ADDR_hostname_string"
380384
}
381385
} else {
382386
user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
383387
}
384388
} else {
385389
--- auto.def
+++ auto.def
@@ -375,10 +375,14 @@
375 # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
376 if {[string match *-darwin* [get-define host]]} {
377 if {[cctest -cflags {-Wdeprecated-declarations}]} {
378 define-append EXTRA_CFLAGS -Wdeprecated-declarations
379 }
 
 
 
 
380 }
381 } else {
382 user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
383 }
384 } else {
385
--- auto.def
+++ auto.def
@@ -375,10 +375,14 @@
375 # Silence OpenSSL deprecation warnings on Mac OS X 10.7.
376 if {[string match *-darwin* [get-define host]]} {
377 if {[cctest -cflags {-Wdeprecated-declarations}]} {
378 define-append EXTRA_CFLAGS -Wdeprecated-declarations
379 }
380 }
381 if {[cc-check-function-in-lib BIO_ADDR_hostname_string ssl]} {
382 define HAVE_BIO_ADDR_HS 1
383 msg-result "Using BIO_ADDR_hostname_string"
384 }
385 } else {
386 user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
387 }
388 } else {
389
+5 -5
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -387,19 +387,19 @@
387387
/* Set the Global.zIpAddr variable to the server we are talking to.
388388
** This is used to populate the ipaddr column of the rcvfrom table,
389389
** if any files are received from the server.
390390
*/
391391
{
392
-#if OPENSSL_VERSION_NUMBER < 0x10100000
392
+#ifdef HAVE_BIO_ADDR_HS
393
+ char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1);
394
+ g.zIpAddr = mprintf("%s", ip);
395
+ OPENSSL_free(ip);
396
+#else
393397
/* IPv4 only code */
394398
const unsigned char *ip;
395399
ip = (const unsigned char*)BIO_ptr_ctrl(iBio,BIO_C_GET_CONNECT,2);
396400
g.zIpAddr = mprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
397
-#else
398
- char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1);
399
- g.zIpAddr = mprintf("%s", ip);
400
- OPENSSL_free(ip);
401401
#endif
402402
}
403403
404404
X509_free(cert);
405405
return 0;
406406
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -387,19 +387,19 @@
387 /* Set the Global.zIpAddr variable to the server we are talking to.
388 ** This is used to populate the ipaddr column of the rcvfrom table,
389 ** if any files are received from the server.
390 */
391 {
392 #if OPENSSL_VERSION_NUMBER < 0x10100000
 
 
 
 
393 /* IPv4 only code */
394 const unsigned char *ip;
395 ip = (const unsigned char*)BIO_ptr_ctrl(iBio,BIO_C_GET_CONNECT,2);
396 g.zIpAddr = mprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
397 #else
398 char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1);
399 g.zIpAddr = mprintf("%s", ip);
400 OPENSSL_free(ip);
401 #endif
402 }
403
404 X509_free(cert);
405 return 0;
406
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -387,19 +387,19 @@
387 /* Set the Global.zIpAddr variable to the server we are talking to.
388 ** This is used to populate the ipaddr column of the rcvfrom table,
389 ** if any files are received from the server.
390 */
391 {
392 #ifdef HAVE_BIO_ADDR_HS
393 char *ip = BIO_ADDR_hostname_string(BIO_get_conn_address(iBio),1);
394 g.zIpAddr = mprintf("%s", ip);
395 OPENSSL_free(ip);
396 #else
397 /* IPv4 only code */
398 const unsigned char *ip;
399 ip = (const unsigned char*)BIO_ptr_ctrl(iBio,BIO_C_GET_CONNECT,2);
400 g.zIpAddr = mprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
 
 
 
 
401 #endif
402 }
403
404 X509_free(cert);
405 return 0;
406

Keyboard Shortcuts

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